﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using S7.Net;

namespace thinger.VisionDemo
{
    public partial class Frm压碎值装置 : Form
    {
        Plc siemens;
        private System.Threading.Timer _timer4;
        private System.Threading.Timer _timer5;
        public Frm压碎值装置()
        {
            InitializeComponent();
            // 创建计时器，但不立即启动
            _timer4 = new System.Threading.Timer(TimerCallback4, null, Timeout.Infinite, Timeout.Infinite);
            _timer5 = new System.Threading.Timer(TimerCallback5, null, Timeout.Infinite, Timeout.Infinite);
        }

        bool 跨坐伺服组同步状态;
        short 捣棒伺服使能;
        short 标定桶伺服使能;
        short 平行移动伺服左使能;
        short 平行移动伺服右使能;
        short 跨坐伺服使能;
        short 毛刷伺服使能;
        short 磁吸伺服使能;
        short 震动升降伺服1使能;
        short 震动升降伺服2使能;
        short 震动升降伺服3使能;
        short 层间升降伺服使能;
        short 倒料伺服使能;
        short 拆模压机伺服1使能;
        short 拆模压机伺服2使能;
        short 拆模压机伺服3使能;

        float 捣棒伺服实际位置;
        float 标定桶伺服实际位置;
        float 平行移动伺服左实际位置;
        float 平行移动伺服右实际位置;
        float 跨坐伺服实际位置;
        float 毛刷伺服实际位置;
        float 磁吸伺服实际位置;
        float 震动升降伺服1实际位置;
        float 震动升降伺服2实际位置;
        float 震动升降伺服3实际位置;
        float 层间升降伺服实际位置;
        float 倒料伺服实际位置;
        float 拆模压机伺服1实际位置;
        float 拆模压机伺服2实际位置;
        float 拆模压机伺服3实际位置;


        bool 捣棒伺服状态;
        bool 标定桶伺服状态;
        bool 平行移动伺服左状态;
        bool 平行移动伺服右状态;
        bool 跨坐伺服状态;
        bool 毛刷伺服状态;
        bool 磁吸伺服状态;
        bool 震动升降伺服1状态;
        bool 震动升降伺服2状态;
        bool 震动升降伺服3状态;
        bool 层间升降伺服状态;
        bool 倒料伺服状态;
        bool 拆模压机伺服1状态;
        bool 拆模压机伺服2状态;
        bool 拆模压机伺服3状态;

        bool 夹紧1前Q;
        bool 夹紧1后Q;
        bool 夹紧2前Q;
        bool 夹紧2后Q;
        bool 夹紧3前Q;
        bool 夹紧3后Q;
        bool 夹紧4前Q;
        bool 夹紧4后Q;
        bool 夹紧5前Q;
        bool 夹紧5后Q;
        bool 夹紧6前Q;
        bool 夹紧6后Q;
        bool 双轴1前Q;
        bool 双轴1后Q;
        bool 双轴2前Q;
        bool 双轴2后Q;
        bool 气缸1前Q;
        bool 气缸1后Q;
        bool 气缸2前Q;
        bool 气缸2后Q;
        bool 气缸3前Q;
        bool 气缸3后Q;
        bool 气缸4前Q;
        bool 气缸4后Q;
        bool 左旋前Q;
        bool 左旋后Q;
        bool 右旋前Q;
        bool 右旋后Q;
        bool 气振动1Q;
        bool 气振动2Q;
        bool 电机1Q;
        bool 电机2Q;
        bool 吸盘7AQ;
        bool 吸盘7BQ;
        bool 吸盘15Q;
        bool 吸盘1Q;
        bool 振动电机;
        bool 压机关Q;
        bool 七号磁条调向Q;


        private void TimerCallback4(object state)
        {
            // 这里模拟获取数据（在后台线程）
            //string timeString = System.DateTime.Now.ToString("HH:mm:ss.fff");
            //btn_平行移动伺服左同步.Text = timeString;
            //读取跨坐伺服组同步状态
            if (ckb_平行移动伺服左保持刷新.Checked)
                跨坐伺服组同步状态 = (bool)siemens.Read(DataType.DataBlock, 3, 508, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {跨坐伺服组同步状态}");
            //读取捣棒伺服使能状态
            if (ckb_捣棒伺服保持刷新.Checked)
                捣棒伺服使能 = (short)siemens.Read(DataType.DataBlock, 3, 2, VarType.Int, 1);
            //Console.WriteLine($"读取值: {捣棒伺服使能}");
            //读取标定桶伺服使能状态
            if (ckb_标定桶伺服保持刷新.Checked)
                标定桶伺服使能 = (short)siemens.Read(DataType.DataBlock, 3, 36, VarType.Int, 1);
            //Console.WriteLine($"读取值: {标定桶伺服使能}");
            //读取平行移动伺服左使能状态
            if (ckb_平行移动伺服左保持刷新.Checked)
                平行移动伺服左使能 = (short)siemens.Read(DataType.DataBlock, 3, 70, VarType.Int, 1);
            //Console.WriteLine($"读取值: {平行移动伺服左使能}");
            //读取平行移动伺服右使能状态
            if (ckb_平行移动伺服右保持刷新.Checked)
                平行移动伺服右使能 = (short)siemens.Read(DataType.DataBlock, 3, 104, VarType.Int, 1);
            //Console.WriteLine($"读取值: {平行移动伺服右使能}");
            //读取跨坐伺服使能状态
            if (ckb_跨坐伺服保持刷新.Checked)
                跨坐伺服使能 = (short)siemens.Read(DataType.DataBlock, 3, 138, VarType.Int, 1);
            //Console.WriteLine($"读取值: {跨坐伺服使能}");
            //读取毛刷伺服使能状态
            if (ckb_毛刷伺服保持刷新.Checked)
                毛刷伺服使能 = (short)siemens.Read(DataType.DataBlock, 3, 172, VarType.Int, 1);
            //Console.WriteLine($"读取值: {毛刷伺服使能}");
            //读取磁吸伺服使能状态
            if (ckb_磁吸伺服保持刷新.Checked)
                磁吸伺服使能 = (short)siemens.Read(DataType.DataBlock, 3, 206, VarType.Int, 1);
            //Console.WriteLine($"读取值: {磁吸伺服使能}");
            //读取震动升降伺服1使能状态
            if (ckb_震动升降伺服1保持刷新.Checked)
                震动升降伺服1使能 = (short)siemens.Read(DataType.DataBlock, 3, 240, VarType.Int, 1);
            //Console.WriteLine($"读取值: {震动升降伺服1使能}");
            //读取震动升降伺服2使能状态
            if (ckb_震动升降伺服2保持刷新.Checked)
                震动升降伺服2使能 = (short)siemens.Read(DataType.DataBlock, 3, 274, VarType.Int, 1);
            //Console.WriteLine($"读取值: {震动升降伺服2使能}");
            //读取震动升降伺服3使能状态
            if (ckb_震动升降伺服3保持刷新.Checked)
                震动升降伺服3使能 = (short)siemens.Read(DataType.DataBlock, 3, 376, VarType.Int, 1);
            //Console.WriteLine($"读取值: {震动升降伺服3使能}");
            //读取层间升降伺服使能状态
            if (ckb_层间升降伺服保持刷新.Checked)
                层间升降伺服使能 = (short)siemens.Read(DataType.DataBlock, 3, 308, VarType.Int, 1);
            //Console.WriteLine($"读取值: {层间升降伺服使能}");
            //读取倒料伺服使能状态
            if (ckb_倒料伺服保持刷新.Checked)
                倒料伺服使能 = (short)siemens.Read(DataType.DataBlock, 3, 478, VarType.Int, 1);
            //Console.WriteLine($"读取值: {倒料伺服使能}");
            //读取拆模压机伺服1使能状态
            if (ckb_拆模压机伺服1保持刷新.Checked)
                拆模压机伺服1使能 = (short)siemens.Read(DataType.DataBlock, 3, 410, VarType.Int, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服1使能}");
            //读取拆模压机伺服2使能状态
            if (ckb_拆模压机伺服2保持刷新.Checked)
                拆模压机伺服2使能 = (short)siemens.Read(DataType.DataBlock, 3, 444, VarType.Int, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服2使能}");
            //读取拆模压机伺服3使能状态
            if (ckb_拆模压机伺服3保持刷新.Checked)
                拆模压机伺服3使能 = (short)siemens.Read(DataType.DataBlock, 3, 342, VarType.Int, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服3使能}");




            //读取 捣棒伺服实际位置
            if (ckb_捣棒伺服保持刷新.Checked)
                捣棒伺服实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 24, VarType.Real, 1);
            //Console.WriteLine($"读取值: {捣棒伺服实际位置}");
            //读取标定桶伺服实际位置
            if (ckb_标定桶伺服保持刷新.Checked)
                标定桶伺服实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 58, VarType.Real, 1);
            //Console.WriteLine($"读取值: {标定桶伺服实际位置}");
            //读取平行移动伺服左实际位置
            if (ckb_平行移动伺服左保持刷新.Checked)
                平行移动伺服左实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 92, VarType.Real, 1);
            //Console.WriteLine($"读取值: {平行移动伺服左实际位置}");
            //读取平行移动伺服右实际位置
            if (ckb_平行移动伺服右保持刷新.Checked)
                平行移动伺服右实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 126, VarType.Real, 1);
            //Console.WriteLine($"读取值: {平行移动伺服右实际位置}");
            //读取跨坐伺服实际位置
            if (ckb_跨坐伺服保持刷新.Checked)
                跨坐伺服实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 160, VarType.Real, 1);
            //Console.WriteLine($"读取值: {跨坐伺服实际位置}");
            //读取毛刷伺服实际位置
            if (ckb_毛刷伺服保持刷新.Checked)
                毛刷伺服实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 194, VarType.Real, 1);
            //Console.WriteLine($"读取值: {毛刷伺服实际位置}");
            //读取磁吸伺服实际位置
            if (ckb_磁吸伺服保持刷新.Checked)
                磁吸伺服实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 228, VarType.Real, 1);
            //Console.WriteLine($"读取值: {磁吸伺服实际位置}");
            //读取震动升降伺服1实际位置
            if (ckb_震动升降伺服1保持刷新.Checked)
                震动升降伺服1实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 262, VarType.Real, 1);
            //Console.WriteLine($"读取值: {震动升降伺服1实际位置}");
            //读取震动升降伺服2实际位置
            if (ckb_震动升降伺服2保持刷新.Checked)
                震动升降伺服2实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 296, VarType.Real, 1);
            //Console.WriteLine($"读取值: {震动升降伺服2实际位置}");
            //读取震动升降伺服3实际位置
            if (ckb_震动升降伺服3保持刷新.Checked)
                震动升降伺服3实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 398, VarType.Real, 1);
            //Console.WriteLine($"读取值: {震动升降伺服3实际位置}");
            //读取层间升降伺服实际位置
            if (ckb_层间升降伺服保持刷新.Checked)
                层间升降伺服实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 330, VarType.Real, 1);
            //Console.WriteLine($"读取值: {层间升降伺服实际位置}");
            //读取倒料伺服实际位置
            if (ckb_倒料伺服保持刷新.Checked)
                倒料伺服实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 500, VarType.Real, 1);
            //Console.WriteLine($"读取值: {倒料伺服实际位置}");
            //读取拆模压机伺服1实际位置
            if (ckb_拆模压机伺服1保持刷新.Checked)
                拆模压机伺服1实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 432, VarType.Real, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服1实际位置}");
            //读取拆模压机伺服2实际位置
            if (ckb_拆模压机伺服2保持刷新.Checked)
                拆模压机伺服2实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 466, VarType.Real, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服2实际位置}");
            //读取 拆模压机伺服3实际位置
            if (ckb_拆模压机伺服3保持刷新.Checked)
                拆模压机伺服3实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 364, VarType.Real, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服3实际位置}");


            //读取捣棒伺服状态
            if (ckb_捣棒伺服保持刷新.Checked)
                捣棒伺服状态 = (bool)siemens.Read(DataType.DataBlock, 3, 32, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {捣棒伺服状态}");
            //读取标定桶伺服状态
            if (ckb_标定桶伺服保持刷新.Checked)
                标定桶伺服状态 = (bool)siemens.Read(DataType.DataBlock, 3, 66, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {标定桶伺服状态}");
            //读取平行移动伺服左状态
            if (ckb_平行移动伺服左保持刷新.Checked)
                平行移动伺服左状态 = (bool)siemens.Read(DataType.DataBlock, 3, 100, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {平行移动伺服左状态}");
            //读取平行移动伺服右状态
            if (ckb_平行移动伺服右保持刷新.Checked)
                平行移动伺服右状态 = (bool)siemens.Read(DataType.DataBlock, 3, 134, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {平行移动伺服右状态}");
            //读取跨坐伺服状态
            if (ckb_跨坐伺服保持刷新.Checked)
                跨坐伺服状态 = (bool)siemens.Read(DataType.DataBlock, 3, 168, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {跨坐伺服状态}");
            //读取毛刷伺服状态
            if (ckb_毛刷伺服保持刷新.Checked)
                毛刷伺服状态 = (bool)siemens.Read(DataType.DataBlock, 3, 202, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {毛刷伺服状态}");
            //读取磁吸伺服状态
            if (ckb_磁吸伺服保持刷新.Checked)
                磁吸伺服状态 = (bool)siemens.Read(DataType.DataBlock, 3, 236, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {磁吸伺服状态}");
            //读取震动升降伺服1状态
            if (ckb_震动升降伺服1保持刷新.Checked)
                震动升降伺服1状态 = (bool)siemens.Read(DataType.DataBlock, 3, 270, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {震动升降伺服1状态}");
            //读取震动升降伺服2状态
            if (ckb_震动升降伺服2保持刷新.Checked)
                震动升降伺服2状态 = (bool)siemens.Read(DataType.DataBlock, 3, 304, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {震动升降伺服2状态}");
            //读取震动升降伺服3状态
            if (ckb_震动升降伺服3保持刷新.Checked)
                震动升降伺服3状态 = (bool)siemens.Read(DataType.DataBlock, 3, 406, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {震动升降伺服3状态}");
            //读取层间升降伺服状态
            if (ckb_层间升降伺服保持刷新.Checked)
                层间升降伺服状态 = (bool)siemens.Read(DataType.DataBlock, 3, 338, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {层间升降伺服状态}");
            //读取倒料伺服状态
            if (ckb_倒料伺服保持刷新.Checked)
                倒料伺服状态 = (bool)siemens.Read(DataType.DataBlock, 3, 508, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {倒料伺服状态}");
            //读取拆模压机伺服1状态
            if (ckb_拆模压机伺服1保持刷新.Checked)
                拆模压机伺服1状态 = (bool)siemens.Read(DataType.DataBlock, 3, 440, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {拆模压机伺服1状态}");
            //读取拆模压机伺服2状态
            if (ckb_拆模压机伺服2保持刷新.Checked)
                拆模压机伺服2状态 = (bool)siemens.Read(DataType.DataBlock, 3, 474, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {拆模压机伺服2状态}");
            //读取拆模压机伺服3状态
            if (ckb_拆模压机伺服3保持刷新.Checked)
                拆模压机伺服3状态 = (bool)siemens.Read(DataType.DataBlock, 3, 372, VarType.Bit, 1, 0);
                //Console.WriteLine($"读取值: {拆模压机伺服3状态}");


            // 使用BeginInvoke将更新操作封送到UI线程
            BeginInvoke((Action)(() =>
            {

                #region 更新UI控件状态

                if (ckb_平行移动伺服左保持刷新.Checked)
                {
                    if (跨坐伺服组同步状态)
                    {
                        if (btn_平行移动伺服左同步.BackColor != Color.Red)
                            btn_平行移动伺服左同步.BackColor = Color.Red;
                        if (btn_平行移动伺服左不同步.BackColor != Color.FromArgb(0, 0, 64))
                            btn_平行移动伺服左不同步.BackColor = Color.FromArgb(0, 0, 64);
                    }
                    else
                    {
                        if (btn_平行移动伺服左同步.BackColor != Color.FromArgb(0, 0, 64))
                            btn_平行移动伺服左同步.BackColor = Color.FromArgb(0, 0, 64);
                        if (btn_平行移动伺服左不同步.BackColor != Color.Red)
                            btn_平行移动伺服左不同步.BackColor = Color.Red;
                    } 
                }

                if (ckb_捣棒伺服保持刷新.Checked)
                {
                    if (捣棒伺服使能 == (short)1)
                    {
                        if (btn_捣棒伺服使能.BackColor != Color.Red)
                            btn_捣棒伺服使能.BackColor = Color.Red;
                    }
                    else
                    {
                        if (btn_捣棒伺服使能.BackColor != Color.FromArgb(0, 0, 64))
                            btn_捣棒伺服使能.BackColor = Color.FromArgb(0, 0, 64);
                    } 
                }

                if (ckb_标定桶伺服保持刷新.Checked)
                {
                    if (标定桶伺服使能 == (short)1)
                    {
                        if (btn_标定桶伺服使能.BackColor != Color.Red)
                            btn_标定桶伺服使能.BackColor = Color.Red;
                    }
                    else
                    {
                        if (btn_标定桶伺服使能.BackColor != Color.FromArgb(0, 0, 64))
                            btn_标定桶伺服使能.BackColor = Color.FromArgb(0, 0, 64);
                    } 
                }

                if (ckb_平行移动伺服左保持刷新.Checked)
                {
                    if (平行移动伺服左使能 == (short)1)
                    {
                        if (btn_平行移动伺服左使能.BackColor != Color.Red)
                            btn_平行移动伺服左使能.BackColor = Color.Red;
                    }
                    else
                    {
                        if (btn_平行移动伺服左使能.BackColor != Color.FromArgb(0, 0, 64))
                            btn_平行移动伺服左使能.BackColor = Color.FromArgb(0, 0, 64);
                    } 
                }

                if (ckb_平行移动伺服右保持刷新.Checked)
                {
                    if (平行移动伺服右使能 == (short)1)
                    {
                        if (btn_平行移动伺服右使能.BackColor != Color.Red)
                            btn_平行移动伺服右使能.BackColor = Color.Red;
                    }
                    else
                    {
                        if (btn_平行移动伺服右使能.BackColor != Color.FromArgb(0, 0, 64))
                            btn_平行移动伺服右使能.BackColor = Color.FromArgb(0, 0, 64);
                    } 
                }

                if (ckb_跨坐伺服保持刷新.Checked)
                {
                    if (跨坐伺服使能 == (short)1)
                    {
                        if (btn_跨坐伺服使能.BackColor != Color.Red)
                            btn_跨坐伺服使能.BackColor = Color.Red;
                    }
                    else
                    {
                        if (btn_跨坐伺服使能.BackColor != Color.FromArgb(0, 0, 64))
                            btn_跨坐伺服使能.BackColor = Color.FromArgb(0, 0, 64);
                    } 
                }

                if (ckb_毛刷伺服保持刷新.Checked)
                {
                    if (毛刷伺服使能 == (short)1)
                    {
                        if (btn_毛刷伺服使能.BackColor != Color.Red)
                            btn_毛刷伺服使能.BackColor = Color.Red;
                    }
                    else
                    {
                        if (btn_毛刷伺服使能.BackColor != Color.FromArgb(0, 0, 64))
                            btn_毛刷伺服使能.BackColor = Color.FromArgb(0, 0, 64);
                    } 
                }

                if (ckb_磁吸伺服保持刷新.Checked)
                {
                    if (磁吸伺服使能 == (short)1)
                    {
                        if (btn_磁吸伺服使能.BackColor != Color.Red)
                            btn_磁吸伺服使能.BackColor = Color.Red;
                    }
                    else
                    {
                        if (btn_磁吸伺服使能.BackColor != Color.FromArgb(0, 0, 64))
                            btn_磁吸伺服使能.BackColor = Color.FromArgb(0, 0, 64);
                    } 
                }

                if (ckb_震动升降伺服1保持刷新.Checked)
                {
                    if (震动升降伺服1使能 == (short)1)
                    {
                        if (btn_震动升降伺服1使能.BackColor != Color.Red)
                            btn_震动升降伺服1使能.BackColor = Color.Red;
                    }
                    else
                    {
                        if (btn_震动升降伺服1使能.BackColor != Color.FromArgb(0, 0, 64))
                            btn_震动升降伺服1使能.BackColor = Color.FromArgb(0, 0, 64);
                    } 
                }

                if (ckb_震动升降伺服2保持刷新.Checked)
                {
                    if (震动升降伺服2使能 == (short)1)
                    {
                        if (btn_震动升降伺服2使能.BackColor != Color.Red)
                            btn_震动升降伺服2使能.BackColor = Color.Red;
                    }
                    else
                    {
                        if (btn_震动升降伺服2使能.BackColor != Color.FromArgb(0, 0, 64))
                            btn_震动升降伺服2使能.BackColor = Color.FromArgb(0, 0, 64);
                    } 
                }

                if (ckb_震动升降伺服3保持刷新.Checked)
                {
                    if (震动升降伺服3使能 == (short)1)
                    {
                        if (btn_震动升降伺服3使能.BackColor != Color.Red)
                            btn_震动升降伺服3使能.BackColor = Color.Red;
                    }
                    else
                    {
                        if (btn_震动升降伺服3使能.BackColor != Color.FromArgb(0, 0, 64))
                            btn_震动升降伺服3使能.BackColor = Color.FromArgb(0, 0, 64);
                    } 
                }

                if (ckb_层间升降伺服保持刷新.Checked)
                {
                    if (层间升降伺服使能 == (short)1)
                    {
                        if (btn_层间升降伺服使能.BackColor != Color.Red)
                            btn_层间升降伺服使能.BackColor = Color.Red;
                    }
                    else
                    {
                        if (btn_层间升降伺服使能.BackColor != Color.FromArgb(0, 0, 64))
                            btn_层间升降伺服使能.BackColor = Color.FromArgb(0, 0, 64);
                    } 
                }

                if (ckb_倒料伺服保持刷新.Checked)
                {
                    if (倒料伺服使能 == (short)1)
                    {
                        if (btn_倒料伺服使能.BackColor != Color.Red)
                            btn_倒料伺服使能.BackColor = Color.Red;
                    }
                    else
                    {
                        if (btn_倒料伺服使能.BackColor != Color.FromArgb(0, 0, 64))
                            btn_倒料伺服使能.BackColor = Color.FromArgb(0, 0, 64);
                    } 
                }

                if (ckb_拆模压机伺服1保持刷新.Checked)
                {
                    if (拆模压机伺服1使能 == (short)1)
                    {
                        if (btn_拆模压机伺服1使能.BackColor != Color.Red)
                            btn_拆模压机伺服1使能.BackColor = Color.Red;
                    }
                    else
                    {
                        if (btn_拆模压机伺服1使能.BackColor != Color.FromArgb(0, 0, 64))
                            btn_拆模压机伺服1使能.BackColor = Color.FromArgb(0, 0, 64);
                    } 
                }

                if (ckb_拆模压机伺服2保持刷新.Checked)
                {
                    if (拆模压机伺服2使能 == (short)1)
                    {
                        if (btn_拆模压机伺服2使能.BackColor != Color.Red)
                            btn_拆模压机伺服2使能.BackColor = Color.Red;
                    }
                    else
                    {
                        if (btn_拆模压机伺服2使能.BackColor != Color.FromArgb(0, 0, 64))
                            btn_拆模压机伺服2使能.BackColor = Color.FromArgb(0, 0, 64);
                    } 
                }

                if (ckb_拆模压机伺服3保持刷新.Checked)
                {
                    if (拆模压机伺服3使能 == (short)1)
                    {
                        if (btn_拆模压机伺服3使能.BackColor != Color.Red)
                            btn_拆模压机伺服3使能.BackColor = Color.Red;
                    }
                    else
                    {
                        if (btn_拆模压机伺服3使能.BackColor != Color.FromArgb(0, 0, 64))
                            btn_拆模压机伺服3使能.BackColor = Color.FromArgb(0, 0, 64);
                    } 
                }


                if (ckb_捣棒伺服保持刷新.Checked)
                {
                    if (txt_捣棒伺服实际位置.Text != 捣棒伺服实际位置.ToString())
                        txt_捣棒伺服实际位置.Text = 捣棒伺服实际位置.ToString(); 
                }

                if (ckb_标定桶伺服保持刷新.Checked)
                {
                    if (txt_标定桶伺服实际位置.Text != 标定桶伺服实际位置.ToString())
                        txt_标定桶伺服实际位置.Text = 标定桶伺服实际位置.ToString(); 
                }

                if (ckb_平行移动伺服左保持刷新.Checked)
                {
                    if (txt_平行移动伺服左实际位置.Text != 平行移动伺服左实际位置.ToString())
                        txt_平行移动伺服左实际位置.Text = 平行移动伺服左实际位置.ToString(); 
                }

                if (ckb_平行移动伺服右保持刷新.Checked)
                {
                    if (txt_平行移动伺服右实际位置.Text != 平行移动伺服右实际位置.ToString())
                        txt_平行移动伺服右实际位置.Text = 平行移动伺服右实际位置.ToString(); 
                }

                if (ckb_跨坐伺服保持刷新.Checked)
                {
                    if (txt_跨坐伺服实际位置.Text != 跨坐伺服实际位置.ToString())
                        txt_跨坐伺服实际位置.Text = 跨坐伺服实际位置.ToString(); 
                }

                if (ckb_毛刷伺服保持刷新.Checked)
                {
                    if (txt_毛刷伺服实际位置.Text != 毛刷伺服实际位置.ToString())
                        txt_毛刷伺服实际位置.Text = 毛刷伺服实际位置.ToString(); 
                }

                if (ckb_磁吸伺服保持刷新.Checked)
                {
                    if (txt_磁吸伺服实际位置.Text != 磁吸伺服实际位置.ToString())
                        txt_磁吸伺服实际位置.Text = 磁吸伺服实际位置.ToString(); 
                }

                if (ckb_震动升降伺服1保持刷新.Checked)
                {
                    if (txt_震动升降伺服1实际位置.Text != 震动升降伺服1实际位置.ToString())
                        txt_震动升降伺服1实际位置.Text = 震动升降伺服1实际位置.ToString(); 
                }

                if (ckb_震动升降伺服2保持刷新.Checked)
                {
                    if (txt_震动升降伺服2实际位置.Text != 震动升降伺服2实际位置.ToString())
                        txt_震动升降伺服2实际位置.Text = 震动升降伺服2实际位置.ToString(); 
                }

                if (ckb_震动升降伺服3保持刷新.Checked)
                {
                    if (txt_震动升降伺服3实际位置.Text != 震动升降伺服3实际位置.ToString())
                        txt_震动升降伺服3实际位置.Text = 震动升降伺服3实际位置.ToString(); 
                }

                if (ckb_层间升降伺服保持刷新.Checked)
                {
                    if (txt_层间升降伺服实际位置.Text != 层间升降伺服实际位置.ToString())
                        txt_层间升降伺服实际位置.Text = 层间升降伺服实际位置.ToString(); 
                }

                if (ckb_倒料伺服保持刷新.Checked)
                {
                    if (txt_倒料伺服实际位置.Text != 倒料伺服实际位置.ToString())
                        txt_倒料伺服实际位置.Text = 倒料伺服实际位置.ToString(); 
                }

                if (ckb_拆模压机伺服1保持刷新.Checked)
                {
                    if (txt_拆模压机伺服1实际位置.Text != 拆模压机伺服1实际位置.ToString())
                        txt_拆模压机伺服1实际位置.Text = 拆模压机伺服1实际位置.ToString(); 
                }

                if (ckb_拆模压机伺服2保持刷新.Checked)
                {
                    if (txt_拆模压机伺服2实际位置.Text != 拆模压机伺服2实际位置.ToString())
                        txt_拆模压机伺服2实际位置.Text = 拆模压机伺服2实际位置.ToString(); 
                }

                if (ckb_拆模压机伺服3保持刷新.Checked)
                {
                    if (txt_拆模压机伺服3实际位置.Text != 拆模压机伺服3实际位置.ToString())
                        txt_拆模压机伺服3实际位置.Text = 拆模压机伺服3实际位置.ToString(); 
                }


                if (ckb_捣棒伺服保持刷新.Checked)
                {
                    if (捣棒伺服状态 == true)
                    {
                        if (lbl_捣棒伺服状态.ForeColor != Color.Red)
                            lbl_捣棒伺服状态.ForeColor = Color.Red;
                    }
                    else
                    {
                        if (lbl_捣棒伺服状态.ForeColor != Color.Blue)
                            lbl_捣棒伺服状态.ForeColor = Color.Blue;
                    } 
                }

                if (ckb_标定桶伺服保持刷新.Checked)
                {
                    if (标定桶伺服状态 == true)
                    {
                        if (lbl_标定桶伺服状态.ForeColor != Color.Red)
                            lbl_标定桶伺服状态.ForeColor = Color.Red;
                    }
                    else
                    {
                        if (lbl_标定桶伺服状态.ForeColor != Color.Blue)
                            lbl_标定桶伺服状态.ForeColor = Color.Blue;
                    }

                }

                if (ckb_平行移动伺服左保持刷新.Checked)
                {
                    if (平行移动伺服左状态 == true)
                    {
                        if (lbl_平行移动伺服左状态.ForeColor != Color.Red)
                            lbl_平行移动伺服左状态.ForeColor = Color.Red;
                    }
                    else
                    {
                        if (lbl_平行移动伺服左状态.ForeColor != Color.Blue)
                            lbl_平行移动伺服左状态.ForeColor = Color.Blue;
                    } 
                }

                if (ckb_平行移动伺服右保持刷新.Checked)
                {
                    if (平行移动伺服右状态 == true)
                    {
                        if (lbl_平行移动伺服右状态.ForeColor != Color.Red)
                            lbl_平行移动伺服右状态.ForeColor = Color.Red;
                    }
                    else
                    {
                        if (lbl_平行移动伺服右状态.ForeColor != Color.Blue)
                            lbl_平行移动伺服右状态.ForeColor = Color.Blue;
                    } 
                }

                if (ckb_跨坐伺服保持刷新.Checked)
                {
                    if (跨坐伺服状态 == true)
                    {
                        if (lbl_跨坐伺服状态.ForeColor != Color.Red)
                            lbl_跨坐伺服状态.ForeColor = Color.Red;
                    }
                    else
                    {
                        if (lbl_跨坐伺服状态.ForeColor != Color.Blue)
                            lbl_跨坐伺服状态.ForeColor = Color.Blue;
                    } 
                }

                if (ckb_毛刷伺服保持刷新.Checked)
                {
                    if (毛刷伺服状态 == true)
                    {
                        if (lbl_毛刷伺服状态.ForeColor != Color.Red)
                            lbl_毛刷伺服状态.ForeColor = Color.Red;
                    }
                    else
                    {
                        if (lbl_毛刷伺服状态.ForeColor != Color.Blue)
                            lbl_毛刷伺服状态.ForeColor = Color.Blue;
                    } 
                }

                if (ckb_磁吸伺服保持刷新.Checked)
                {
                    if (磁吸伺服状态 == true)
                    {
                        if (lbl_磁吸伺服状态.ForeColor != Color.Red)
                            lbl_磁吸伺服状态.ForeColor = Color.Red;
                    }
                    else
                    {
                        if (lbl_磁吸伺服状态.ForeColor != Color.Blue)
                            lbl_磁吸伺服状态.ForeColor = Color.Blue;
                    } 
                }

                if (ckb_震动升降伺服1保持刷新.Checked)
                {
                    if (震动升降伺服1状态 == true)
                    {
                        if (lbl_震动升降伺服1状态.ForeColor != Color.Red)
                            lbl_震动升降伺服1状态.ForeColor = Color.Red;
                    }
                    else
                    {
                        if (lbl_震动升降伺服1状态.ForeColor != Color.Blue)
                            lbl_震动升降伺服1状态.ForeColor = Color.Blue;
                    } 
                }

                if (ckb_震动升降伺服2保持刷新.Checked)
                {
                    if (震动升降伺服2状态 == true)
                    {
                        if (lbl_震动升降伺服2状态.ForeColor != Color.Red)
                            lbl_震动升降伺服2状态.ForeColor = Color.Red;
                    }
                    else
                    {
                        if (lbl_震动升降伺服2状态.ForeColor != Color.Blue)
                            lbl_震动升降伺服2状态.ForeColor = Color.Blue;
                    } 
                }

                if (ckb_震动升降伺服3保持刷新.Checked)
                {
                    if (震动升降伺服3状态 == true)
                    {
                        if (lbl_震动升降伺服3状态.ForeColor != Color.Red)
                            lbl_震动升降伺服3状态.ForeColor = Color.Red;
                    }
                    else
                    {
                        if (lbl_震动升降伺服3状态.ForeColor != Color.Blue)
                            lbl_震动升降伺服3状态.ForeColor = Color.Blue;
                    } 
                }

                if (ckb_层间升降伺服保持刷新.Checked)
                {
                    if (层间升降伺服状态 == true)
                    {
                        if (lbl_层间升降伺服状态.ForeColor != Color.Red)
                            lbl_层间升降伺服状态.ForeColor = Color.Red;
                    }
                    else
                    {
                        if (lbl_层间升降伺服状态.ForeColor != Color.Blue)
                            lbl_层间升降伺服状态.ForeColor = Color.Blue;
                    } 
                }

                if (ckb_倒料伺服保持刷新.Checked)
                {
                    if (倒料伺服状态 == true)
                    {
                        if (lbl_倒料伺服状态.ForeColor != Color.Red)
                            lbl_倒料伺服状态.ForeColor = Color.Red;
                    }
                    else
                    {
                        if (lbl_倒料伺服状态.ForeColor != Color.Blue)
                            lbl_倒料伺服状态.ForeColor = Color.Blue;
                    } 
                }

                if (ckb_拆模压机伺服1保持刷新.Checked)
                {
                    if (拆模压机伺服1状态 == true)
                    {
                        if (lbl_拆模压机伺服1状态.ForeColor != Color.Red)
                            lbl_拆模压机伺服1状态.ForeColor = Color.Red;
                    }
                    else
                    {
                        if (lbl_拆模压机伺服1状态.ForeColor != Color.Blue)
                            lbl_拆模压机伺服1状态.ForeColor = Color.Blue;
                    } 
                }

                if (ckb_拆模压机伺服2保持刷新.Checked)
                {
                    if (拆模压机伺服2状态 == true)
                    {
                        if (lbl_拆模压机伺服2状态.ForeColor != Color.Red)
                            lbl_拆模压机伺服2状态.ForeColor = Color.Red;
                    }
                    else
                    {
                        if (lbl_拆模压机伺服2状态.ForeColor != Color.Blue)
                            lbl_拆模压机伺服2状态.ForeColor = Color.Blue;
                    } 
                }


                if (ckb_拆模压机伺服3保持刷新.Checked)
                {
                    if (拆模压机伺服3状态 == true)
                    {
                        if (lbl_拆模压机伺服3状态.ForeColor != Color.Red)
                            lbl_拆模压机伺服3状态.ForeColor = Color.Red;
                    }
                    else
                    {
                        if (lbl_拆模压机伺服3状态.ForeColor != Color.Blue)
                            lbl_拆模压机伺服3状态.ForeColor = Color.Blue;
                    } 
                }

                #endregion

            }));
        }
        private void TimerCallback5(object state)
        {
            // 这里模拟获取数据（在后台线程）
            //string timeString = System.DateTime.Now.ToString("HH:mm:ss.fff");
            //btn_平行移动伺服左同步.Text = timeString;

            //读取状态
            夹紧1前Q = (bool)siemens.Read("Q8.0");
            夹紧1后Q = (bool)siemens.Read("Q8.1");
            夹紧2前Q = (bool)siemens.Read("Q8.2");
            夹紧2后Q = (bool)siemens.Read("Q8.3");
            夹紧3前Q = (bool)siemens.Read("Q8.4");
            夹紧3后Q = (bool)siemens.Read("Q8.5");
            夹紧4前Q = (bool)siemens.Read("Q8.6");
            夹紧4后Q = (bool)siemens.Read("Q8.7");
            夹紧5前Q = (bool)siemens.Read("Q9.0");
            夹紧5后Q = (bool)siemens.Read("Q9.1");
            夹紧6前Q = (bool)siemens.Read("Q9.2");
            夹紧6后Q = (bool)siemens.Read("Q9.3");
            双轴1前Q = (bool)siemens.Read("Q9.4");
            双轴1后Q = (bool)siemens.Read("Q9.5");
            双轴2前Q = (bool)siemens.Read("Q9.6");
            双轴2后Q = (bool)siemens.Read("Q9.7");
            气缸1前Q = (bool)siemens.Read("Q12.0");
            气缸1后Q = (bool)siemens.Read("Q12.1");
            气缸2前Q = (bool)siemens.Read("Q12.2");
            气缸2后Q = (bool)siemens.Read("Q12.3");
            气缸3前Q = (bool)siemens.Read("Q12.4");
            气缸3后Q = (bool)siemens.Read("Q12.5");
            气缸4前Q = (bool)siemens.Read("Q12.6");
            气缸4后Q = (bool)siemens.Read("Q12.7");
            左旋前Q = (bool)siemens.Read("Q13.0");
            左旋后Q = (bool)siemens.Read("Q13.1");
            右旋前Q = (bool)siemens.Read("Q13.2");
            右旋后Q = (bool)siemens.Read("Q13.3");
            气振动1Q = (bool)siemens.Read("Q13.4");
            气振动2Q = (bool)siemens.Read("Q13.5");
            电机1Q = (bool)siemens.Read("Q17.0");
            电机2Q = (bool)siemens.Read("Q17.1");
            吸盘7AQ = (bool)siemens.Read("Q17.2");
            吸盘7BQ = (bool)siemens.Read("Q17.3");
            吸盘15Q = (bool)siemens.Read("Q17.4");
            吸盘1Q = (bool)siemens.Read("Q17.5");
            振动电机 = (bool)siemens.Read("Q17.7");
            压机关Q = (bool)siemens.Read("Q0.2");
            七号磁条调向Q = (bool)siemens.Read("Q0.5");





            // 使用BeginInvoke将更新操作封送到UI线程
            BeginInvoke((Action)(() =>
            {

                #region 更新UI控件状态
                if (夹紧1前Q)
                {
                    btn_夹紧1前.BackColor = Color.Red;
                }
                else
                {
                    btn_夹紧1前.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (夹紧1后Q)
                {
                    btn_夹紧1后.BackColor = Color.Red;
                }
                else
                {
                    btn_夹紧1后.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (夹紧2前Q)
                {
                    btn_夹紧2前.BackColor = Color.Red;
                }
                else
                {
                    btn_夹紧2前.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (夹紧2后Q)
                {
                    btn_夹紧2后.BackColor = Color.Red;
                }
                else
                {
                    btn_夹紧2后.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (夹紧3前Q)
                {
                    btn_夹紧3前.BackColor = Color.Red;
                }
                else
                {
                    btn_夹紧3前.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (夹紧3后Q)
                {
                    btn_夹紧3后.BackColor = Color.Red;
                }
                else
                {
                    btn_夹紧3后.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (夹紧4前Q)
                {
                    btn_夹紧4前.BackColor = Color.Red;
                }
                else
                {
                    btn_夹紧4前.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (夹紧4后Q)
                {
                    btn_夹紧4后.BackColor = Color.Red;
                }
                else
                {
                    btn_夹紧4后.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (夹紧5前Q)
                {
                    btn_夹紧5前.BackColor = Color.Red;
                }
                else
                {
                    btn_夹紧5前.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (夹紧5后Q)
                {
                    btn_夹紧5后.BackColor = Color.Red;
                }
                else
                {
                    btn_夹紧5后.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (夹紧6前Q)
                {
                    btn_夹紧6前.BackColor = Color.Red;
                }
                else
                {
                    btn_夹紧6前.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (夹紧6后Q)
                {
                    btn_夹紧6后.BackColor = Color.Red;
                }
                else
                {
                    btn_夹紧6后.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (双轴1前Q)
                {
                    btn_双轴1前.BackColor = Color.Red;
                }
                else
                {
                    btn_双轴1前.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (双轴1后Q)
                {
                    btn_双轴1后.BackColor = Color.Red;
                }
                else
                {
                    btn_双轴1后.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (双轴2前Q)
                {
                    btn_双轴2前.BackColor = Color.Red;
                }
                else
                {
                    btn_双轴2前.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (双轴2后Q)
                {
                    btn_双轴2后.BackColor = Color.Red;
                }
                else
                {
                    btn_双轴2后.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (气缸1前Q)
                {
                    btn_气缸1前.BackColor = Color.Red;
                }
                else
                {
                    btn_气缸1前.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (气缸1后Q)
                {
                    btn_气缸1后.BackColor = Color.Red;
                }
                else
                {
                    btn_气缸1后.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (气缸2前Q)
                {
                    btn_气缸2前.BackColor = Color.Red;
                }
                else
                {
                    btn_气缸2前.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (气缸2后Q)
                {
                    btn_气缸2后.BackColor = Color.Red;
                }
                else
                {
                    btn_气缸2后.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (气缸3前Q)
                {
                    btn_气缸3前.BackColor = Color.Red;
                }
                else
                {
                    btn_气缸3前.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (气缸3后Q)
                {
                    btn_气缸3后.BackColor = Color.Red;
                }
                else
                {
                    btn_气缸3后.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (气缸4前Q)
                {
                    btn_气缸4前.BackColor = Color.Red;
                }
                else
                {
                    btn_气缸4前.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (气缸4后Q)
                {
                    btn_气缸4后.BackColor = Color.Red;
                }
                else
                {
                    btn_气缸4后.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (左旋前Q)
                {
                    btn_左旋前.BackColor = Color.Red;
                }
                else
                {
                    btn_左旋前.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (左旋后Q)
                {
                    btn_左旋后.BackColor = Color.Red;
                }
                else
                {
                    btn_左旋后.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (右旋前Q)
                {
                    btn_右旋前.BackColor = Color.Red;
                }
                else
                {
                    btn_右旋前.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (右旋后Q)
                {
                    btn_右旋后.BackColor = Color.Red;
                }
                else
                {
                    btn_右旋后.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (气振动1Q)
                {
                    btn_气振1启.BackColor = Color.Red;
                }
                else
                {
                    btn_气振1启.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (气振动2Q)
                {
                    btn_气振2启.BackColor = Color.Red;
                }
                else
                {
                    btn_气振2启.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (电机1Q)
                {
                    btn_电机1启.BackColor = Color.Red;
                }
                else
                {
                    btn_电机1启.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (电机2Q)
                {
                    btn_电机2启.BackColor = Color.Red;
                }
                else
                {
                    btn_电机2启.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (吸盘7AQ)
                {
                    btn_吸盘1A启.BackColor = Color.Red;
                }
                else
                {
                    btn_吸盘1A启.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (吸盘7BQ)
                {
                    btn_振动1B启.BackColor = Color.Red;
                }
                else
                {
                    btn_振动1B启.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (吸盘15Q)
                {
                    btn_吸盘2启.BackColor = Color.Red;
                }
                else
                {
                    btn_吸盘2启.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (吸盘1Q)
                {
                    btn_吸盘3启.BackColor = Color.Red;
                }
                else
                {
                    btn_吸盘3启.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (振动电机)
                {
                    btn_振动电机启.BackColor = Color.Red;
                }
                else
                {
                    btn_振动电机启.BackColor = Color.FromArgb(0, 0, 64);
                }

                if (七号磁条调向Q)
                {
                    btn_电机2反.BackColor = Color.Red;
                }
                else
                {
                    btn_电机2反.BackColor = Color.FromArgb(0, 0, 64);
                }




                #endregion

            }));
        }


        private void btnPlcConnect_Click(object sender, EventArgs e)
        {
            try
            {


                siemens = new Plc(CpuType.S71200, txtPlcIP.Text, 102, 0, 1);
                //siemens = new Plc(CpuType.S71200, "47.98.145.26", 8040, 0, 1);//wanhui-nps


                // 连接对象
                siemens.Open();
                if (!siemens.IsConnected)
                {
                    lblStatus.Text = "连接PLC失败！";
                }
                else
                {
                    lblStatus.Text = "连接PLC成功！";
                    readInitialValue();
                }




            }
            catch (Exception err)
            {
                MessageBox.Show("参数错误，请检查！" + err.Message);
            }

        }

        private void readInitialValue()
        {

            //读取捣棒伺服模式设定
            short 捣棒伺服模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 0, VarType.Int, 1);
            //Console.WriteLine($"读取值: {捣棒伺服模式设定}");
            txt_捣棒伺服模式设定.Text = 捣棒伺服模式设定.ToString();

            //读取标定桶伺服模式设定
            short 标定桶伺服模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 34, VarType.Int, 1);
            //Console.WriteLine($"读取值: {标定桶伺服模式设定}");
            txt_标定桶伺服模式设定.Text = 标定桶伺服模式设定.ToString();

            //读取平行移动伺服左模式设定
            short 平行移动伺服左模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 68, VarType.Int, 1);
            //Console.WriteLine($"读取值: {平行移动伺服左模式设定}");
            txt_平行移动伺服左模式设定.Text = 平行移动伺服左模式设定.ToString();

            //读取平行移动伺服右模式设定
            short 平行移动伺服右模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 102, VarType.Int, 1);
            //Console.WriteLine($"读取值: {平行移动伺服右模式设定}");
            txt_平行移动伺服右模式设定.Text = 平行移动伺服右模式设定.ToString();

            //读取跨坐伺服模式设定
            short 跨坐伺服模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 136, VarType.Int, 1);
            //Console.WriteLine($"读取值: {跨坐伺服模式设定}");
            txt_跨坐伺服模式设定.Text = 跨坐伺服模式设定.ToString();

            //读取毛刷伺服模式设定
            short 毛刷伺服模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 170, VarType.Int, 1);
            //Console.WriteLine($"读取值: {毛刷伺服模式设定}");
            txt_毛刷伺服模式设定.Text = 毛刷伺服模式设定.ToString();

            //读取磁吸伺服模式设定
            short 磁吸伺服模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 204, VarType.Int, 1);
            //Console.WriteLine($"读取值: {磁吸伺服模式设定}");
            txt_磁吸伺服模式设定.Text = 磁吸伺服模式设定.ToString();

            //读取震动升降伺服1模式设定
            short 震动升降伺服1模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 238, VarType.Int, 1);
            //Console.WriteLine($"读取值: {震动升降伺服1模式设定}");
            txt_震动升降伺服1模式设定.Text = 震动升降伺服1模式设定.ToString();

            //读取震动升降伺服2模式设定
            short 震动升降伺服2模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 272, VarType.Int, 1);
            //Console.WriteLine($"读取值: {震动升降伺服2模式设定}");
            txt_震动升降伺服2模式设定.Text = 震动升降伺服2模式设定.ToString();

            //读取震动升降伺服3模式设定
            short 震动升降伺服3模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 374, VarType.Int, 1);
            //Console.WriteLine($"读取值: {震动升降伺服3模式设定}");
            txt_震动升降伺服3模式设定.Text = 震动升降伺服3模式设定.ToString();

            //读取层间升降伺服模式设定
            short 层间升降伺服模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 306, VarType.Int, 1);
            //Console.WriteLine($"读取值: {层间升降伺服模式设定}");
            txt_层间升降伺服模式设定.Text = 层间升降伺服模式设定.ToString();

            //读取倒料伺服模式设定
            short 倒料伺服模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 476, VarType.Int, 1);
            //Console.WriteLine($"读取值: {倒料伺服模式设定}");
            txt_倒料伺服模式设定.Text = 倒料伺服模式设定.ToString();

            //读取拆模压机伺服1模式设定
            short 拆模压机伺服1模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 408, VarType.Int, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服1模式设定}");
            txt_拆模压机伺服1模式设定.Text = 拆模压机伺服1模式设定.ToString();

            //读取拆模压机伺服2模式设定
            short 拆模压机伺服2模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 442, VarType.Int, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服2模式设定}");
            txt_拆模压机伺服2模式设定.Text = 拆模压机伺服2模式设定.ToString();

            //读取拆模压机伺服3模式设定
            short 拆模压机伺服3模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 340, VarType.Int, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服3模式设定}");
            txt_拆模压机伺服3模式设定.Text = 拆模压机伺服3模式设定.ToString();




            //读取捣棒伺服目标位置
            float 捣棒伺服目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 6, VarType.Real, 1);
            //Console.WriteLine($"读取值: {捣棒伺服目标位置}");
            txt_捣棒伺服目标位置.Text = 捣棒伺服目标位置.ToString();

            //读取标定桶伺服目标位置
            float 标定桶伺服目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 40, VarType.Real, 1);
            //Console.WriteLine($"读取值: {标定桶伺服目标位置}");
            txt_标定桶伺服目标位置.Text = 标定桶伺服目标位置.ToString();

            //读取平行移动伺服左目标位置
            float 平行移动伺服左目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 74, VarType.Real, 1);
            //Console.WriteLine($"读取值: {平行移动伺服左目标位置}");
            txt_平行移动伺服左目标位置.Text = 平行移动伺服左目标位置.ToString();

            //读取平行移动伺服右目标位置
            float 平行移动伺服右目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 108, VarType.Real, 1);
            //Console.WriteLine($"读取值: {平行移动伺服右目标位置}");
            txt_平行移动伺服右目标位置.Text = 平行移动伺服右目标位置.ToString();

            //读取跨坐伺服目标位置
            float 跨坐伺服目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 142, VarType.Real, 1);
            //Console.WriteLine($"读取值: {跨坐伺服目标位置}");
            txt_跨坐伺服目标位置.Text = 跨坐伺服目标位置.ToString();

            //读取毛刷伺服目标位置
            float 毛刷伺服目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 176, VarType.Real, 1);
            //Console.WriteLine($"读取值: {毛刷伺服目标位置}");
            txt_毛刷伺服目标位置.Text = 毛刷伺服目标位置.ToString();

            //读取磁吸伺服目标位置
            float 磁吸伺服目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 210, VarType.Real, 1);
            //Console.WriteLine($"读取值: {磁吸伺服目标位置}");
            txt_磁吸伺服目标位置.Text = 磁吸伺服目标位置.ToString();

            //读取震动升降伺服1目标位置
            float 震动升降伺服1目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 244, VarType.Real, 1);
            //Console.WriteLine($"读取值: {震动升降伺服1目标位置}");
            txt_震动升降伺服1目标位置.Text = 震动升降伺服1目标位置.ToString();

            //读取震动升降伺服2目标位置
            float 震动升降伺服2目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 278, VarType.Real, 1);
            //Console.WriteLine($"读取值: {震动升降伺服2目标位置}");
            txt_震动升降伺服2目标位置.Text = 震动升降伺服2目标位置.ToString();

            //读取震动升降伺服3目标位置
            float 震动升降伺服3目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 380, VarType.Real, 1);
            //Console.WriteLine($"读取值: {震动升降伺服3目标位置}");
            txt_震动升降伺服3目标位置.Text = 震动升降伺服3目标位置.ToString();

            //读取层间升降伺服目标位置
            float 层间升降伺服目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 312, VarType.Real, 1);
            //Console.WriteLine($"读取值: {层间升降伺服目标位置}");
            txt_层间升降伺服目标位置.Text = 层间升降伺服目标位置.ToString();

            //读取倒料伺服目标位置
            float 倒料伺服目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 482, VarType.Real, 1);
            //Console.WriteLine($"读取值: {倒料伺服目标位置}");
            txt_倒料伺服目标位置.Text = 倒料伺服目标位置.ToString();

            //读取拆模压机伺服1目标位置
            float 拆模压机伺服1目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 414, VarType.Real, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服1目标位置}");
            txt_拆模压机伺服1目标位置.Text = 拆模压机伺服1目标位置.ToString();

            //读取拆模压机伺服2目标位置
            float 拆模压机伺服2目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 448, VarType.Real, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服2目标位置}");
            txt_拆模压机伺服2目标位置.Text = 拆模压机伺服2目标位置.ToString();

            //读取拆模压机伺服3目标位置
            float 拆模压机伺服3目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 346, VarType.Real, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服3目标位置}");
            txt_拆模压机伺服3目标位置.Text = 拆模压机伺服3目标位置.ToString();



        }


        private void btnPlcDisconnect_Click(object sender, EventArgs e)
        {
            try
            {
                siemens.Close();
                lblStatus.Text = "PLC断开连接！";
                //updateTimer.Enabled = false;
            }
            catch
            {
                MessageBox.Show("参数错误，请检查！");
            }
        }

        private void btn_捣棒伺服模式设定_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 0, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            ushort newValue = ushort.Parse(txt_捣棒伺服模式设定.Text);
            siemens.Write(DataType.DataBlock, 3, 0, newValue);

            //读取捣棒伺服模式设定
            short 捣棒伺服模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 0, VarType.Int, 1);
            //Console.WriteLine($"读取值: {捣棒伺服模式设定}");
            txt_捣棒伺服模式设定.Text = 捣棒伺服模式设定.ToString();
        }

        private void btn_捣棒伺服长度限制设定_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 18, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_捣棒伺服长度限制.Text);

            siemens.Write(DataType.DataBlock, 3, 18, newValue);

            //读取捣棒伺服长度限制设定
            float 捣棒伺服长度限制 = (float)siemens.Read(DataType.DataBlock, 3, 18, VarType.Real, 1);
            //Console.WriteLine($"读取值: {捣棒伺服长度限制}");
            txt_捣棒伺服长度限制.Text = 捣棒伺服长度限制.ToString();
        }

        private void btn_捣棒伺服目标位置_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 6, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_捣棒伺服目标位置.Text);

            siemens.Write(DataType.DataBlock, 3, 6, newValue);

            //读取料桶升降伺服目标设定
            float 捣棒伺服目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 6, VarType.Real, 1);
            //Console.WriteLine($"读取值: {捣棒伺服目标位置}");
            txt_捣棒伺服目标位置.Text = 捣棒伺服目标位置.ToString();
        }

        private void btn_StartTimer_Click(object sender, EventArgs e)
        {
            btn_StartTimer.BackColor = Color.DodgerBlue;
            btn_StopTimer.BackColor = Color.FromArgb(0,0,64);
            // 启动计时器，每秒更新一次（1000毫秒）
            if (siemens != null && siemens.IsConnected)
            {
                _timer4.Change(0, 1000);

            }
            else
            {

            }
        }

        private void btn_StopTimer_Click(object sender, EventArgs e)
        {
            btn_StartTimer.BackColor = Color.FromArgb(0, 0, 64);
            btn_StopTimer.BackColor = Color.DodgerBlue;
            // 停止计时器
            _timer4.Change(Timeout.Infinite, Timeout.Infinite);
        }

        private void btn_捣棒伺服使能_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 2, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            if ((short)siemens.Read(DataType.DataBlock, 3, 2, VarType.Int, 1) == (short)1)
            {
                siemens.Write(DataType.DataBlock, 3, 2, (short)0);
            }
            else
            {
                siemens.Write(DataType.DataBlock, 3, 2, (short)1);
            }
        }

        private void btn_捣棒伺服启动_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 4, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 4, 4, true);
        }

        private void btn_捣棒伺服启动_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 4, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 4, 4, false);
        }

        private void btn_捣棒伺服点动1_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 4, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 4, 1, true);
        }

        private void btn_捣棒伺服点动1_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 4, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 4, 1, false);
        }

        private void btn_捣棒伺服点动2_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 4, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 4, 2, true);
        }

        private void btn_捣棒伺服点动2_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 4, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 4, 2, false);
        }

        private void btn_标定桶伺服模式设定_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 34, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            ushort newValue = ushort.Parse(txt_标定桶伺服模式设定.Text);
            siemens.Write(DataType.DataBlock, 3, 34, newValue);

            //读取标定桶伺服模式设定
            short 标定桶伺服模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 34, VarType.Int, 1);
            //Console.WriteLine($"读取值: {标定桶伺服模式设定}");
            txt_标定桶伺服模式设定.Text = 标定桶伺服模式设定.ToString();
        }

        private void btn_标定桶伺服长度限制_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 52, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_标定桶伺服长度限制.Text);

            siemens.Write(DataType.DataBlock, 3, 52, newValue);

            //读取标定桶伺服长度限制
            float 标定桶伺服长度限制 = (float)siemens.Read(DataType.DataBlock, 3, 52, VarType.Real, 1);
            //Console.WriteLine($"读取值: {标定桶伺服长度限制}");
            txt_标定桶伺服长度限制.Text = 标定桶伺服长度限制.ToString();
        }

        private void btn_标定桶伺服目标位置_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 40, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_标定桶伺服目标位置.Text);

            siemens.Write(DataType.DataBlock, 3, 40, newValue);

            //读取标定桶伺服目标设定
            float 标定桶伺服目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 40, VarType.Real, 1);
            //Console.WriteLine($"读取值: {标定桶伺服目标位置}");
            txt_标定桶伺服目标位置.Text = 标定桶伺服目标位置.ToString();
        }

        private void btn_标定桶伺服使能_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 36, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            if ((short)siemens.Read(DataType.DataBlock, 3, 36, VarType.Int, 1) == (short)1)
            {
                siemens.Write(DataType.DataBlock, 3, 36, (short)0);
            }
            else
            {
                siemens.Write(DataType.DataBlock, 3, 36, (short)1);
            }
        }

        private void btn_标定桶伺服启动_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 38, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 38, 4, true);
        }

        private void btn_标定桶伺服启动_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 38, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 38, 4, false);
        }

        private void btn_标定桶伺服点动1_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 38, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 38, 1, true);
        }

        private void btn_标定桶伺服点动1_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 38, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 38, 1, false);
        }

        private void btn_标定桶伺服点动2_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 38, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 38, 2, true);
        }

        private void btn_标定桶伺服点动2_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 38, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 38, 2, false);
        }

        private void btn_平行移动伺服左模式设定_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 68, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            ushort newValue = ushort.Parse(txt_平行移动伺服左模式设定.Text);
            siemens.Write(DataType.DataBlock, 3, 68, newValue);

            //读取平行移动伺服左模式设定
            short 平行移动伺服左模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 68, VarType.Int, 1);
            //Console.WriteLine($"读取值: {平行移动伺服左模式设定}");
            txt_平行移动伺服左模式设定.Text = 平行移动伺服左模式设定.ToString();
        }

        private void btn_平行移动伺服左长度限制_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 86, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_平行移动伺服左长度限制.Text);

            siemens.Write(DataType.DataBlock, 3, 86, newValue);

            //读取平行移动伺服左长度限制
            float 平行移动伺服左长度限制 = (float)siemens.Read(DataType.DataBlock, 3, 86, VarType.Real, 1);
            //Console.WriteLine($"读取值: {平行移动伺服左长度限制}");
            txt_平行移动伺服左长度限制.Text = 平行移动伺服左长度限制.ToString();
        }

        private void btn_平行移动伺服左目标位置_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 74, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_平行移动伺服左目标位置.Text);

            siemens.Write(DataType.DataBlock, 3, 74, newValue);

            //读取平行移动伺服左目标设定
            float 平行移动伺服左目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 74, VarType.Real, 1);
            //Console.WriteLine($"读取值: {平行移动伺服左目标位置}");
            txt_平行移动伺服左目标位置.Text = 平行移动伺服左目标位置.ToString();
        }

        private void btn_平行移动伺服左使能_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 70, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            if ((short)siemens.Read(DataType.DataBlock, 3, 70, VarType.Int, 1) == (short)1)
            {
                siemens.Write(DataType.DataBlock, 3, 70, (short)0);
            }
            else
            {
                siemens.Write(DataType.DataBlock, 3, 70, (short)1);
            }

        }

        private void btn_平行移动伺服左启动_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 72, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 72, 4, true);
        }

        private void btn_平行移动伺服左启动_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 72, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 72, 4, false);
        }

        private void btn_平行移动伺服左点动1_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 72, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 72, 1, true);
        }

        private void btn_平行移动伺服左点动1_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 72, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 72, 1, false);
        }

        private void btn_平行移动伺服左点动2_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 72, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 72, 2, true);
        }

        private void btn_平行移动伺服左点动2_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 72, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 72, 2, false);
        }

        private void btn_平行移动伺服右模式设定_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 102, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            ushort newValue = ushort.Parse(txt_平行移动伺服右模式设定.Text);
            siemens.Write(DataType.DataBlock, 3, 102, newValue);

            //读取平行移动伺服右模式设定
            short 平行移动伺服右模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 102, VarType.Int, 1);
            //Console.WriteLine($"读取值: {平行移动伺服右模式设定}");
            txt_平行移动伺服右模式设定.Text = 平行移动伺服右模式设定.ToString();
        }

        private void btn_跨坐伺服模式设定_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 136, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            ushort newValue = ushort.Parse(txt_跨坐伺服模式设定.Text);
            siemens.Write(DataType.DataBlock, 3, 136, newValue);

            //读取跨坐伺服模式设定
            short 跨坐伺服模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 136, VarType.Int, 1);
            //Console.WriteLine($"读取值: {跨坐伺服模式设定}");
            txt_跨坐伺服模式设定.Text = 跨坐伺服模式设定.ToString();
        }

        private void btn_毛刷伺服模式设定_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 170, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            ushort newValue = ushort.Parse(txt_毛刷伺服模式设定.Text);
            siemens.Write(DataType.DataBlock, 3, 170, newValue);

            //读取毛刷伺服模式设定
            short 毛刷伺服模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 170, VarType.Int, 1);
            //Console.WriteLine($"读取值: {毛刷伺服模式设定}");
            txt_毛刷伺服模式设定.Text = 毛刷伺服模式设定.ToString();
        }

        private void btn_磁吸伺服模式设定_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 204, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            ushort newValue = ushort.Parse(txt_磁吸伺服模式设定.Text);
            siemens.Write(DataType.DataBlock, 3, 204, newValue);

            //读取磁吸伺服模式设定
            short 磁吸伺服模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 204, VarType.Int, 1);
            //Console.WriteLine($"读取值: {磁吸伺服模式设定}");
            txt_磁吸伺服模式设定.Text = 磁吸伺服模式设定.ToString();
        }

        private void btn_震动升降伺服1模式设定_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 238, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            ushort newValue = ushort.Parse(txt_震动升降伺服1模式设定.Text);
            siemens.Write(DataType.DataBlock, 3, 238, newValue);

            //读取震动升降伺服1模式设定
            short 震动升降伺服1模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 238, VarType.Int, 1);
            //Console.WriteLine($"读取值: {震动升降伺服1模式设定}");
            txt_震动升降伺服1模式设定.Text = 震动升降伺服1模式设定.ToString();
        }

        private void btn_震动升降伺服2模式设定_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 272, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            ushort newValue = ushort.Parse(txt_震动升降伺服2模式设定.Text);
            siemens.Write(DataType.DataBlock, 3, 272, newValue);

            //读取震动升降伺服2模式设定
            short 震动升降伺服2模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 272, VarType.Int, 1);
            //Console.WriteLine($"读取值: {震动升降伺服2模式设定}");
            txt_震动升降伺服2模式设定.Text = 震动升降伺服2模式设定.ToString();
        }

        private void btn_震动升降伺服3模式设定_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 374, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            ushort newValue = ushort.Parse(txt_震动升降伺服3模式设定.Text);
            siemens.Write(DataType.DataBlock, 3, 374, newValue);

            //读取震动升降伺服3模式设定
            short 震动升降伺服3模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 374, VarType.Int, 1);
            //Console.WriteLine($"读取值: {震动升降伺服2模式设定}");
            txt_震动升降伺服3模式设定.Text = 震动升降伺服3模式设定.ToString();
        }

        private void btn_层间升降伺服模式设定_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 306, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            ushort newValue = ushort.Parse(txt_层间升降伺服模式设定.Text);
            siemens.Write(DataType.DataBlock, 3, 306, newValue);

            //读取层间升降伺服模式设定
            short 层间升降伺服模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 306, VarType.Int, 1);
            //Console.WriteLine($"读取值: {层间升降伺服模式设定}");
            txt_层间升降伺服模式设定.Text = 层间升降伺服模式设定.ToString();
        }

        private void btn_倒料伺服模式设定_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 476, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            ushort newValue = ushort.Parse(txt_倒料伺服模式设定.Text);
            siemens.Write(DataType.DataBlock, 3, 476, newValue);

            //读取倒料伺服模式设定
            short 倒料伺服模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 476, VarType.Int, 1);
            //Console.WriteLine($"读取值: {倒料伺服模式设定}");
            txt_倒料伺服模式设定.Text = 倒料伺服模式设定.ToString();
        }

        private void btn_拆模压机伺服1模式设定_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 408, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            ushort newValue = ushort.Parse(txt_拆模压机伺服1模式设定.Text);
            siemens.Write(DataType.DataBlock, 3, 408, newValue);

            //读取拆模压机伺服1模式设定
            short 拆模压机伺服1模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 408, VarType.Int, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服1模式设定}");
            txt_拆模压机伺服1模式设定.Text = 拆模压机伺服1模式设定.ToString();
        }

        private void btn_拆模压机伺服2模式设定_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 442, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            ushort newValue = ushort.Parse(txt_拆模压机伺服2模式设定.Text);
            siemens.Write(DataType.DataBlock, 3, 442, newValue);

            //读取拆模压机伺服2模式设定
            short 拆模压机伺服2模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 442, VarType.Int, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服2模式设定}");
            txt_拆模压机伺服2模式设定.Text = 拆模压机伺服2模式设定.ToString();
        }

        private void btn_拆模压机伺服3模式设定_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 340, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            ushort newValue = ushort.Parse(txt_拆模压机伺服3模式设定.Text);
            siemens.Write(DataType.DataBlock, 3, 340, newValue);

            //读取拆模压机伺服3模式设定
            short 拆模压机伺服3模式设定 = (short)siemens.Read(DataType.DataBlock, 3, 340, VarType.Int, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服3模式设定}");
            txt_拆模压机伺服3模式设定.Text = 拆模压机伺服3模式设定.ToString();
        }

        private void btn_平行移动伺服右长度限制_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 120, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_平行移动伺服右长度限制.Text);

            siemens.Write(DataType.DataBlock, 3, 120, newValue);

            //读取平行移动伺服右长度限制
            float 平行移动伺服右长度限制 = (float)siemens.Read(DataType.DataBlock, 3, 120, VarType.Real, 1);
            //Console.WriteLine($"读取值: {平行移动伺服右长度限制}");
            txt_平行移动伺服右长度限制.Text = 平行移动伺服右长度限制.ToString();
        }

        private void btn_跨坐伺服长度限制_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 154, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_跨坐伺服长度限制.Text);

            siemens.Write(DataType.DataBlock, 3, 154, newValue);

            //读取跨坐伺服长度限制
            float 跨坐伺服长度限制 = (float)siemens.Read(DataType.DataBlock, 3,154, VarType.Real, 1);
            //Console.WriteLine($"读取值: {跨坐伺服长度限制}");
            txt_跨坐伺服长度限制.Text = 跨坐伺服长度限制.ToString();
        }

        private void btn_毛刷伺服长度设定_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 188, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_毛刷伺服长度限制.Text);

            siemens.Write(DataType.DataBlock, 3, 188, newValue);

            //读取毛刷伺服长度限制
            float 毛刷伺服长度限制 = (float)siemens.Read(DataType.DataBlock, 3, 188, VarType.Real, 1);
            //Console.WriteLine($"读取值: {毛刷伺服长度限制}");
            txt_毛刷伺服长度限制.Text = 毛刷伺服长度限制.ToString();
        }

        private void btn_磁吸伺服长度限制_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 222, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_磁吸伺服长度限制.Text);

            siemens.Write(DataType.DataBlock, 3, 222, newValue);

            //读取磁吸伺服长度限制
            float 磁吸伺服长度限制 = (float)siemens.Read(DataType.DataBlock, 3, 222, VarType.Real, 1);
            //Console.WriteLine($"读取值: {磁吸伺服长度限制}");
            txt_磁吸伺服长度限制.Text = 磁吸伺服长度限制.ToString();
        }

        private void btn_震动升降伺服1长度限制_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 256, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_震动升降伺服1长度限制.Text);

            siemens.Write(DataType.DataBlock, 3, 256, newValue);

            //读取震动升降伺服1长度限制
            float 震动升降伺服1长度限制 = (float)siemens.Read(DataType.DataBlock, 3, 256, VarType.Real, 1);
            //Console.WriteLine($"读取值: {震动升降伺服1长度限制}");
            txt_震动升降伺服1长度限制.Text = 震动升降伺服1长度限制.ToString();
        }

        private void btn_震动升降伺服2长度限制_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 290, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_震动升降伺服2长度限制.Text);

            siemens.Write(DataType.DataBlock, 3, 290, newValue);

            //读取震动升降伺服2长度限制
            float 震动升降伺服2长度限制 = (float)siemens.Read(DataType.DataBlock, 3, 290, VarType.Real, 1);
            //Console.WriteLine($"读取值: {震动升降伺服2长度限制}");
            txt_震动升降伺服2长度限制.Text = 震动升降伺服2长度限制.ToString();
        }

        private void btn_震动升降伺服3长度限制_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 392, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_震动升降伺服3长度限制.Text);

            siemens.Write(DataType.DataBlock, 3, 392, newValue);

            //读取震动升降伺服3长度限制
            float 震动升降伺服3长度限制 = (float)siemens.Read(DataType.DataBlock, 3, 392, VarType.Real, 1);
            //Console.WriteLine($"读取值: {震动升降伺服3长度限制}");
            txt_震动升降伺服3长度限制.Text = 震动升降伺服3长度限制.ToString();
        }

        private void btn_层间升降伺服长度限制_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 324, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_层间升降伺服长度限制.Text);

            siemens.Write(DataType.DataBlock, 3, 324, newValue);

            //读取层间升降伺服长度限制
            float 层间升降伺服长度限制 = (float)siemens.Read(DataType.DataBlock, 3, 324, VarType.Real, 1);
            //Console.WriteLine($"读取值: {层间升降伺服长度限制}");
            txt_层间升降伺服长度限制.Text = 层间升降伺服长度限制.ToString();
        }

        private void btn_倒料伺服长度限制_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 494, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_倒料伺服长度限制.Text);

            siemens.Write(DataType.DataBlock, 3, 494, newValue);

            //读取倒料伺服长度限制
            float 倒料伺服长度限制 = (float)siemens.Read(DataType.DataBlock, 3, 494, VarType.Real, 1);
            //Console.WriteLine($"读取值: {倒料伺服长度限制}");
            txt_倒料伺服长度限制.Text = 倒料伺服长度限制.ToString();
        }

        private void btn_拆模压机伺服1长度限制_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 426, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_拆模压机伺服1长度限制.Text);

            siemens.Write(DataType.DataBlock, 3, 426, newValue);

            //读取拆模压机伺服1长度限制
            float 拆模压机伺服1长度限制 = (float)siemens.Read(DataType.DataBlock, 3, 426, VarType.Real, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服1长度限制}");
            txt_拆模压机伺服1长度限制.Text = 拆模压机伺服1长度限制.ToString();
        }

        private void btn_拆模压机伺服2长度限制_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 460, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_拆模压机伺服2长度限制.Text);

            siemens.Write(DataType.DataBlock, 3, 460, newValue);

            //读取拆模压机伺服2长度限制
            float 拆模压机伺服2长度限制 = (float)siemens.Read(DataType.DataBlock, 3, 460, VarType.Real, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服2长度限制}");
            txt_拆模压机伺服2长度限制.Text = 拆模压机伺服2长度限制.ToString();
        }

        private void btn_拆模压机伺服3长度限制_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 358, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_拆模压机伺服3长度限制.Text);

            siemens.Write(DataType.DataBlock, 3, 358, newValue);

            //读取拆模压机伺服3长度限制
            float 拆模压机伺服3长度限制 = (float)siemens.Read(DataType.DataBlock, 3, 358, VarType.Real, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服3长度限制}");
            txt_拆模压机伺服3长度限制.Text = 拆模压机伺服3长度限制.ToString();
        }

        private void btn_平行移动伺服右目标位置_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 108, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_平行移动伺服右目标位置.Text);

            siemens.Write(DataType.DataBlock, 3, 108, newValue);

            //读取平行移动伺服右目标设定
            float 平行移动伺服右目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 108, VarType.Real, 1);
            //Console.WriteLine($"读取值: {平行移动伺服右目标位置}");
            txt_平行移动伺服右目标位置.Text = 平行移动伺服右目标位置.ToString();
        }

        private void btn_跨坐伺服目标位置_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 142, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_跨坐伺服目标位置.Text);

            siemens.Write(DataType.DataBlock, 3, 142, newValue);

            //读取跨坐伺服目标设定
            float 跨坐伺服目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 142, VarType.Real, 1);
            //Console.WriteLine($"读取值: {跨坐伺服目标位置}");
            txt_跨坐伺服目标位置.Text = 跨坐伺服目标位置.ToString();
        }

        private void btn_毛刷伺服目标位置_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 176, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_毛刷伺服目标位置.Text);

            siemens.Write(DataType.DataBlock, 3, 176, newValue);

            //读取毛刷伺服目标设定
            float 毛刷伺服目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 176, VarType.Real, 1);
            //Console.WriteLine($"读取值: {毛刷伺服目标位置}");
            txt_毛刷伺服目标位置.Text = 毛刷伺服目标位置.ToString();
        }

        private void btn_磁吸伺服目标位置_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 210, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_磁吸伺服目标位置.Text);

            siemens.Write(DataType.DataBlock, 3, 210, newValue);

            //读取磁吸伺服目标设定
            float 磁吸伺服目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 210, VarType.Real, 1);
            //Console.WriteLine($"读取值: {磁吸伺服目标位置}");
            txt_磁吸伺服目标位置.Text = 磁吸伺服目标位置.ToString();
        }

        private void btn_震动升降伺服1目标位置_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 244, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_震动升降伺服1目标位置.Text);

            siemens.Write(DataType.DataBlock, 3, 244, newValue);

            //读取震动升降伺服1目标设定
            float 震动升降伺服1目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 244, VarType.Real, 1);
            //Console.WriteLine($"读取值: {震动升降伺服1目标位置}");
            txt_震动升降伺服1目标位置.Text = 震动升降伺服1目标位置.ToString();
        }

        private void btn_震动升降伺服2目标位置_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 278, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_震动升降伺服2目标位置.Text);

            siemens.Write(DataType.DataBlock, 3, 278, newValue);

            //读取震动升降伺服2目标设定
            float 震动升降伺服2目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 278, VarType.Real, 1);
            //Console.WriteLine($"读取值: {震动升降伺服2目标位置}");
            txt_震动升降伺服2目标位置.Text = 震动升降伺服2目标位置.ToString();
        }

        private void btn_震动升降伺服3目标位置_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 380, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_震动升降伺服3目标位置.Text);

            siemens.Write(DataType.DataBlock, 3, 380, newValue);

            //读取震动升降伺服3目标设定
            float 震动升降伺服3目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 380, VarType.Real, 1);
            //Console.WriteLine($"读取值: {震动升降伺服3目标位置}");
            txt_震动升降伺服3目标位置.Text = 震动升降伺服3目标位置.ToString();
        }

        private void btn_层间升降伺服目标位置_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 312, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_层间升降伺服目标位置.Text);

            siemens.Write(DataType.DataBlock, 3, 312, newValue);

            //读取层间升降伺服目标设定
            float 层间升降伺服目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 312, VarType.Real, 1);
            //Console.WriteLine($"读取值: {层间升降伺服目标位置}");
            txt_层间升降伺服目标位置.Text = 层间升降伺服目标位置.ToString();
        }

        private void btn_倒料伺服目标位置_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 482, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_倒料伺服目标位置.Text);

            siemens.Write(DataType.DataBlock, 3, 482, newValue);

            //读取倒料伺服目标设定
            float 倒料伺服目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 482, VarType.Real, 1);
            //Console.WriteLine($"读取值: {倒料伺服目标位置}");
            txt_倒料伺服目标位置.Text = 倒料伺服目标位置.ToString();
        }

        private void btn_拆模压机伺服1目标位置_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 414, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_拆模压机伺服1目标位置.Text);

            siemens.Write(DataType.DataBlock, 3, 414, newValue);

            //读取拆模压机伺服1目标设定
            float 拆模压机伺服1目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 414, VarType.Real, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服1目标位置}");
            txt_拆模压机伺服1目标位置.Text = 拆模压机伺服1目标位置.ToString();
        }

        private void btn_拆模压机伺服2目标位置_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 448, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_拆模压机伺服2目标位置.Text);

            siemens.Write(DataType.DataBlock, 3, 448, newValue);

            //读取拆模压机伺服2目标设定
            float 拆模压机伺服2目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 448, VarType.Real, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服2目标位置}");
            txt_拆模压机伺服2目标位置.Text = 拆模压机伺服2目标位置.ToString();
        }

        private void btn_拆模压机伺服3目标位置_Click(object sender, EventArgs e)
        {
            float valueRead = (float)siemens.Read(DataType.DataBlock, 3, 346, VarType.Real, 1);
            //Console.WriteLine($"读取值: {valueRead}");

            float newValue = float.Parse(txt_拆模压机伺服3目标位置.Text);

            siemens.Write(DataType.DataBlock, 3, 346, newValue);

            //读取拆模压机伺服3目标设定
            float 拆模压机伺服3目标位置 = (float)siemens.Read(DataType.DataBlock, 3, 346, VarType.Real, 1);
            //Console.WriteLine($"读取值: {拆模压机伺服3目标位置}");
            txt_拆模压机伺服3目标位置.Text = 拆模压机伺服3目标位置.ToString();
        }

        private void btn_平行移动伺服右使能_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 104, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            if ((short)siemens.Read(DataType.DataBlock, 3, 104, VarType.Int, 1) == (short)1)
            {
                siemens.Write(DataType.DataBlock, 3, 104, (short)0);
            }
            else
            {
                siemens.Write(DataType.DataBlock, 3, 104, (short)1);
            }
        }

        private void btn_跨坐伺服使能_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 138, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            if ((short)siemens.Read(DataType.DataBlock, 3, 138, VarType.Int, 1) == (short)1)
            {
                siemens.Write(DataType.DataBlock, 3, 138, (short)0);
            }
            else
            {
                siemens.Write(DataType.DataBlock, 3, 138, (short)1);
            }
        }

        private void btn_毛刷伺服使能_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 172, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            if ((short)siemens.Read(DataType.DataBlock, 3, 172, VarType.Int, 1) == (short)1)
            {
                siemens.Write(DataType.DataBlock, 3, 172, (short)0);
            }
            else
            {
                siemens.Write(DataType.DataBlock, 3, 172, (short)1);
            }
        }

        private void btn_磁吸伺服使能_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 206, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            if ((short)siemens.Read(DataType.DataBlock, 3, 206, VarType.Int, 1) == (short)1)
            {
                siemens.Write(DataType.DataBlock, 3, 206, (short)0);
            }
            else
            {
                siemens.Write(DataType.DataBlock, 3, 206, (short)1);
            }
        }

        private void btn_震动升降伺服1使能_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 240, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            if ((short)siemens.Read(DataType.DataBlock, 3, 240, VarType.Int, 1) == (short)1)
            {
                siemens.Write(DataType.DataBlock, 3, 240, (short)0);
            }
            else
            {
                siemens.Write(DataType.DataBlock, 3, 240, (short)1);
            }
        }

        private void btn_震动升降伺服2使能_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 274, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            if ((short)siemens.Read(DataType.DataBlock, 3, 274, VarType.Int, 1) == (short)1)
            {
                siemens.Write(DataType.DataBlock, 3, 274, (short)0);
            }
            else
            {
                siemens.Write(DataType.DataBlock, 3, 274, (short)1);
            }
        }

        private void btn_震动升降伺服3使能_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 376, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            if ((short)siemens.Read(DataType.DataBlock, 3, 376, VarType.Int, 1) == (short)1)
            {
                siemens.Write(DataType.DataBlock, 3, 376, (short)0);
            }
            else
            {
                siemens.Write(DataType.DataBlock, 3, 376, (short)1);
            }
        }

        private void btn_层间升降伺服使能_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 308, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            if ((short)siemens.Read(DataType.DataBlock, 3, 308, VarType.Int, 1) == (short)1)
            {
                siemens.Write(DataType.DataBlock, 3, 308, (short)0);
            }
            else
            {
                siemens.Write(DataType.DataBlock, 3, 308, (short)1);
            }
        }

        private void btn_倒料伺服使能_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 478, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            if ((short)siemens.Read(DataType.DataBlock, 3, 478, VarType.Int, 1) == (short)1)
            {
                siemens.Write(DataType.DataBlock, 3, 478, (short)0);
            }
            else
            {
                siemens.Write(DataType.DataBlock, 3, 478, (short)1);
            }
        }

        private void btn_拆模压机伺服1使能_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 410, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            if ((short)siemens.Read(DataType.DataBlock, 3, 410, VarType.Int, 1) == (short)1)
            {
                siemens.Write(DataType.DataBlock, 3, 410, (short)0);
            }
            else
            {
                siemens.Write(DataType.DataBlock, 3, 410, (short)1);
            }
        }

        private void btn_拆模压机伺服2使能_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 444, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            if ((short)siemens.Read(DataType.DataBlock, 3, 444, VarType.Int, 1) == (short)1)
            {
                siemens.Write(DataType.DataBlock, 3, 444, (short)0);
            }
            else
            {
                siemens.Write(DataType.DataBlock, 3, 444, (short)1);
            }
        }

        private void btn_拆模压机伺服3使能_Click(object sender, EventArgs e)
        {
            short valueRead = (short)siemens.Read(DataType.DataBlock, 3, 342, VarType.Int, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            if ((short)siemens.Read(DataType.DataBlock, 3, 342, VarType.Int, 1) == (short)1)
            {
                siemens.Write(DataType.DataBlock, 3, 342, (short)0);
            }
            else
            {
                siemens.Write(DataType.DataBlock, 3, 342, (short)1);
            }
        }

        private void btn_平行移动伺服右启动_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 106, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 106, 4, true);
        }

        private void btn_平行移动伺服右启动_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 106, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 106, 4, false);
        }

        private void btn_跨坐伺服启动_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 140, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 140, 4, true);
        }

        private void btn_跨坐伺服启动_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 140, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 140, 4, false);
        }

        private void btn_毛刷伺服启动_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 174, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 174, 4, true);
        }

        private void btn_毛刷伺服启动_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 174, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 174, 4, false);
        }

        private void btn_磁吸伺服启动_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 208, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 208, 4, true);
        }

        private void btn_磁吸伺服启动_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 208, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 208, 4, false);
        }

        private void btn_震动升降伺服1启动_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 242, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 242, 4, true);
        }

        private void btn_震动升降伺服1启动_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 242, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 242, 4, false);
        }

        private void btn_震动升降伺服2启动_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 276, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 276, 4, true);
        }

        private void btn_震动升降伺服2启动_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 276, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 276, 4, false);
        }

        private void btn_震动升降伺服3启动_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 378, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 378, 4, true);
        }

        private void btn_震动升降伺服3启动_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 378, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 378, 4, false);
        }

        private void btn_层间升降伺服启动_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 310, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 310, 4, true);
        }

        private void btn_层间升降伺服启动_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 310, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 310, 4, false);
        }

        private void btn_倒料伺服启动_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 480, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 480, 4, true);
        }

        private void btn_倒料伺服启动_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 480, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 480, 4, false);
        }

        private void btn_拆模压机伺服1启动_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 412, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 412, 4, true);
        }

        private void btn_拆模压机伺服1启动_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 412, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 412, 4, false);
        }

        private void btn_拆模压机伺服2启动_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 446, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 446, 4, true);
        }

        private void btn_拆模压机伺服2启动_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 446, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 446, 4, false);
        }

        private void btn_拆模压机伺服3启动_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 344, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 344, 4, true);
        }

        private void btn_拆模压机伺服3启动_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 344, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 344, 4, false);
        }

        private void btn_平行移动伺服右点动1_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 106, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 106, 1, true);
        }

        private void btn_平行移动伺服右点动1_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 106, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 106, 1, false);
        }

        private void btn_平行移动伺服右点动2_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 106, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 106, 2, true);
        }

        private void btn_平行移动伺服右点动2_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 106, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 106, 2, false);
        }

        private void btn_跨坐伺服点动1_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 140, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 140, 1, true);
        }

        private void btn_跨坐伺服点动1_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 140, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 140, 1, false);
        }

        private void btn_跨坐伺服点动2_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 140, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 140, 2, true);
        }

        private void btn_跨坐伺服点动2_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 140, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 140, 2, false);
        }

        private void btn_毛刷伺服点动1_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 174, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 174, 1, true);
        }

        private void btn_毛刷伺服点动1_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 174, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 174, 1, false);
        }

        private void btn_毛刷伺服点动2_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 174, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 174, 2, true);
        }

        private void btn_毛刷伺服点动2_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 174, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 174, 2, false);
        }

        private void btn_磁吸伺服点动1_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 208, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 208, 1, true);
        }

        private void btn_磁吸伺服点动1_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 208, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 208, 1, false);
        }

        private void btn_磁吸伺服点动2_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 208, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 208, 2, true);
        }

        private void btn_磁吸伺服点动2_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 208, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 208, 2, false);
        }

        private void btn_震动升降伺服1点动1_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 242, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 242, 1, true);
        }

        private void btn_震动升降伺服1点动1_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 242, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 242, 1, false);
        }

        private void btn_震动升降伺服1点动2_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 242, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 242, 2, true);
        }

        private void btn_震动升降伺服1点动2_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 242, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 242, 2, false);
        }

        private void btn_震动升降伺服2点动1_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 276, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 276, 1, true);
        }

        private void btn_震动升降伺服2点动1_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 276, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 276, 1, false);
        }

        private void btn_震动升降伺服2点动2_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 276, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 276, 2, true);
        }

        private void btn_震动升降伺服2点动2_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 276, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 276, 2, false);
        }

        private void btn_震动升降伺服3点动1_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 378, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 378, 1, true);
        }

        private void btn_震动升降伺服3点动1_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 378, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 378, 1, false);
        }

        private void btn_震动升降伺服3点动2_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 378, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 378, 2, true);
        }

        private void btn_震动升降伺服3点动2_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 378, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 378, 2, false);
        }

        private void btn_层间升降伺服点动1_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 310, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 310, 1, true);
        }

        private void btn_层间升降伺服点动1_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 310, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 310, 1, false);
        }

        private void btn_层间升降伺服点动2_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 310, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 310, 2, true);
        }

        private void btn_层间升降伺服点动2_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 310, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 310, 2, false);
        }

        private void btn_倒料伺服点动1_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 480, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 480, 1, true);
        }

        private void btn_倒料伺服点动1_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 480, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 480, 1, false);
        }

        private void btn_倒料伺服点动2_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 480, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 480, 2, true);
        }

        private void btn_倒料伺服点动2_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 480, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 480, 2, false);
        }

        private void btn_拆模压机伺服1点动1_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 412, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 412, 1, true);
        }

        private void btn_拆模压机伺服1点动1_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 412, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 412, 1, false);
        }

        private void btn_拆模压机伺服1点动2_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 412, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 412, 2, true);
        }

        private void btn_拆模压机伺服1点动2_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 412, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 412, 2, false);
        }

        private void btn_拆模压机伺服2点动1_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 446, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 446, 1, true);
        }

        private void btn_拆模压机伺服2点动1_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 446, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 446, 1, false);
        }

        private void btn_拆模压机伺服2点动2_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 446, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 446, 2, true);
        }

        private void btn_拆模压机伺服2点动2_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 446, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 446, 2, false);
        }

        private void btn_拆模压机伺服3点动1_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 344, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 344, 1, true);
        }

        private void btn_拆模压机伺服3点动1_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 344, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 344, 1, false);
        }

        private void btn_拆模压机伺服3点动2_MouseDown(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 344, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 344, 2, true);
        }

        private void btn_拆模压机伺服3点动2_MouseUp(object sender, MouseEventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 344, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            siemens.WriteBit(DataType.DataBlock, 3, 344, 2, false);
        }

        private void btn_夹紧1前_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 0, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 0))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 0, 2, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 0, 2, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_夹紧1后_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 0, VarType.Bit, 1, 3);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 0))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 0, 3, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 0, 3, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_夹紧1停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 0, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 0, 4, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 0, 4, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}

        }

        private void btn_夹紧2前_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 0, VarType.Bit, 1, 5);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 0, 5, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 0, 5, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_夹紧2后_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 0, VarType.Bit, 1, 6);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 0, 6, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 0, 6, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}

        }

        private void btn_夹紧2停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 0, VarType.Bit, 1, 7);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 0, 7, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 0, 7, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}

        }

        private void btn_夹紧3前_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 1, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 1, 0, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock,2, 1, 0, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}

        }

        private void btn_夹紧3后_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 1, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 1, 1, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 1, 1, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_夹紧3停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 1, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 1, 2, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 1, 2, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_夹紧4前_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 1, VarType.Bit, 1, 3);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 1, 3, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 1, 3, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_夹紧4后_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 1, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 1, 4, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 1, 4, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_夹紧4停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 1, VarType.Bit, 1, 5);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 1, 5, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 1, 5, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_夹紧5前_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 1, VarType.Bit, 1, 6);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 1, 6, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 1, 6, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_夹紧5后_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 1, VarType.Bit, 1, 7);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 1, 7, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 1, 7, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_夹紧5停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 2, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 2, 0, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 2, 0, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_夹紧6前_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 2, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 2, 1, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 2, 1, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_夹紧6后_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 2, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 2, 2, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 2, 2, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_夹紧6停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 2, VarType.Bit, 1, 3);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 2, 3, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 2, 3, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_气缸1前_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 3, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 3, 2, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 3, 2, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_气缸1后_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 3, VarType.Bit, 1, 3);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 3, 3, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 3, 3, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_气缸1停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 3, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 3, 4, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 3, 4, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_气缸2前_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 3, VarType.Bit, 1, 5);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 3, 5, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 3, 5, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_气缸2后_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 3, VarType.Bit, 1, 6);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 3, 6, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 3, 6, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_气缸2停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 3, VarType.Bit, 1, 7);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 3, 7, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 3, 7, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_气缸3前_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 4, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 4, 0, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 4, 0, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_气缸3后_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 4, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 4, 1, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 4, 1, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_气缸3停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 4, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 4, 2, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 4, 2, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_气缸4前_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 4, VarType.Bit, 1, 3);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 4, 3, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 4, 3, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_气缸后_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 4, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 4, 4, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 4, 4, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_气缸停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 4, VarType.Bit, 1, 5);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 4, 5, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 4, 5, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_左旋前_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 4, VarType.Bit, 1, 6);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 4, 6, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 4, 6, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_左旋后_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 4, VarType.Bit, 1, 7);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 4, 7, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 4, 7, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_左旋停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 5, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 5, 0, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 5, 0, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_右旋前_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 5, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 5, 1, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 5, 1, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_右旋后_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 5, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 5, 2, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 5, 2, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_右旋停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 5, VarType.Bit, 1, 3);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 5, 3, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 5, 3, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_双轴1前_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 2, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 2, 4, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 2, 4, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_双轴1后_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 2, VarType.Bit, 1, 5);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 2, 5, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 2, 5, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_双轴1停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 2, VarType.Bit, 1, 6);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 2, 6, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 2, 6, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_双轴2前_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 2, VarType.Bit, 1, 7);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 2, 7, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 2, 7, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_双轴2后_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 3, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 3, 0, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 3, 0, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_双轴2停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 3, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 4, VarType.Bit, 1, 2))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 3, 1, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 3, 1, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_气振1启_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 5, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 0, VarType.Bit, 1, 0))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 5, 4, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            //siemens.WriteBit(DataType.DataBlock, 2, 5, 4, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_气振1停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 5, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 0, VarType.Bit, 1, 0))
            //{
            //siemens.WriteBit(DataType.DataBlock, 2, 5, 4, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 5, 4, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_气振2启_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 5, VarType.Bit, 1, 5);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 0, VarType.Bit, 1, 0))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 5, 5, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            //siemens.WriteBit(DataType.DataBlock, 2, 5, 5, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_气振2停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 5, VarType.Bit, 1, 5);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 0, VarType.Bit, 1, 0))
            //{
            //siemens.WriteBit(DataType.DataBlock, 2, 5, 5, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 5, 5, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_电机1启_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 5, VarType.Bit, 1, 6);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 0, VarType.Bit, 1, 0))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 5, 6, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            //siemens.WriteBit(DataType.DataBlock, 2, 5, 6, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_电机1停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 5, VarType.Bit, 1, 6);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 0, VarType.Bit, 1, 0))
            //{
            //siemens.WriteBit(DataType.DataBlock, 2, 5, 6, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 5, 6, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_电机2启_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 5, VarType.Bit, 1, 7);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 0, VarType.Bit, 1, 0))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 5, 7, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            //siemens.WriteBit(DataType.DataBlock, 2, 5, 7, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_电机2停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 5, VarType.Bit, 1, 7);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 0, VarType.Bit, 1, 0))
            //{
            //siemens.WriteBit(DataType.DataBlock, 2, 5, 7, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 5, 7, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_吸盘1A启_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 6, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 0, VarType.Bit, 1, 0))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 6, 1, false);
            siemens.WriteBit(DataType.DataBlock, 2, 6, 0, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            //siemens.WriteBit(DataType.DataBlock, 2, 6, 0, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_吸盘1A停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 6, VarType.Bit, 1, 0);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 0, VarType.Bit, 1, 0))
            //{
            //siemens.WriteBit(DataType.DataBlock, 2, 6, 0, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 6, 0, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_振动1B启_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 6, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 0, VarType.Bit, 1, 0))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 6, 0, false);
            siemens.WriteBit(DataType.DataBlock, 2, 6, 1, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            //siemens.WriteBit(DataType.DataBlock, 2, 6, 1, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_振动1B停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 6, VarType.Bit, 1, 1);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 0, VarType.Bit, 1, 0))
            //{
            //siemens.WriteBit(DataType.DataBlock, 2, 6, 1, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 6, 1, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_吸盘2启_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 6, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 0, VarType.Bit, 1, 0))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 6, 2, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            //siemens.WriteBit(DataType.DataBlock, 2, 6, 2, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_吸盘2停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 6, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 0, VarType.Bit, 1, 0))
            //{
            //siemens.WriteBit(DataType.DataBlock, 2, 6, 2, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 6, 2, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_吸盘3启_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 6, VarType.Bit, 1, 3);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 0, VarType.Bit, 1, 0))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 6, 3, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            //siemens.WriteBit(DataType.DataBlock, 2, 6, 3, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_吸盘3停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 6, VarType.Bit, 1, 3);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 0, VarType.Bit, 1, 0))
            //{
            //siemens.WriteBit(DataType.DataBlock, 2, 6, 3, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 6, 3, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_振动电机启_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 6, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 0, VarType.Bit, 1, 0))
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 6, 4, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            //siemens.WriteBit(DataType.DataBlock, 2, 6, 4, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_振动电机停_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 6, VarType.Bit, 1, 4);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 9, 0, VarType.Bit, 1, 0))
            //{
            //siemens.WriteBit(DataType.DataBlock, 2, 6, 4, true);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            siemens.WriteBit(DataType.DataBlock, 2, 6, 4, false);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}
        }

        private void btn_平行移动伺服左同步_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 508, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");

            siemens.WriteBit(DataType.DataBlock, 3, 508, 2, true);
        }

        private void btn_平行移动伺服左不同步_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 3, 508, VarType.Bit, 1, 2);
            //Console.WriteLine($"读取值: {valueRead}");

            siemens.WriteBit(DataType.DataBlock, 3, 508, 2, false);
        }

        private async void btn_标定桶流程_Click(object sender, EventArgs e)
        {
            //初始化状态 
            //伺服驱动器使能
            if ((short)siemens.Read(DataType.DataBlock, 3, 274, VarType.Int, 1) == 0)
                btn_震动升降伺服2使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 308, VarType.Int, 1) == 0)
                btn_层间升降伺服使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 376, VarType.Int, 1) == 0)
                btn_震动升降伺服3使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 410, VarType.Int, 1) == 0)
                btn_拆模压机伺服1使能.PerformClick();

            /*-----------第一次装料-----------*/

            //标定桶模组移动到下料口
            await Task.Delay(2 * 1000);
            await ProcessWithConditionAsync("标定桶伺服", 47.7f);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_标定桶伺服目标位置.Text = "0";
            btn_标定桶伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_标定桶伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_标定桶伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //套筒气缸打开
            await ProcessWithConditionAsync("标定桶伺服", 0);
            //await Task.Delay(20 * 1000);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            btn_双轴2前.PerformClick();
            await Task.Delay(5 * 1000);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            btn_双轴2停.PerformClick();

            //6分气缸开合1
            //await ProcessWithConditionAsync("标定桶伺服", 0);
            await Task.Delay(3 * 1000);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            btn_夹紧1前.PerformClick();
            btn_夹紧3前.PerformClick();
            await Task.Delay(5 * 1000);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            btn_夹紧1停.PerformClick();
            btn_夹紧3停.PerformClick();

            //套筒气缸松开
            await ProcessWithConditionAsync("标定桶伺服", 0);
            //await Task.Delay(20 * 1000);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            btn_双轴2后.PerformClick();
            await Task.Delay(5 * 1000);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            btn_双轴2停.PerformClick();

            //标定桶模组移动到捣棒位
            await ProcessWithConditionAsync("标定桶伺服", 0);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_标定桶伺服目标位置.Text = "27.7";
            btn_标定桶伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_标定桶伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_标定桶伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //捣棒气杆下降加磁吸起捣棒
            await ProcessWithConditionAsync("标定桶伺服", 27.7f);
            btn_双轴1前.PerformClick();
            await Task.Delay(5 * 1000);
            btn_双轴1停.PerformClick();
            await Task.Delay(1 * 1000);
            btn_吸盘1A启.PerformClick();
            await Task.Delay(2 * 1000);
            btn_双轴1后.PerformClick();
            await Task.Delay(5 * 1000);
            btn_双轴1停.PerformClick();

            //捣棒伺服下降到料位1
            await ProcessWithConditionAsync("标定桶伺服", 0);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_捣棒伺服目标位置.Text = "12.7";
            btn_捣棒伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_捣棒伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_捣棒伺服启动_MouseUp(sender, (MouseEventArgs)e);


            //捣棒磁吸消磁捣棒下落
            await ProcessWithConditionAsync("捣棒伺服", 27.7f);
            await Task.Delay(1 * 1000);
            btn_吸盘1A启.PerformClick();

            //捣棒伺服上升
            await Task.Delay(3 * 1000);
            //await ProcessWithConditionAsync("捣棒伺服", 12.7f);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_捣棒伺服目标位置.Text = "12.7";
            btn_捣棒伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_捣棒伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_捣棒伺服启动_MouseUp(sender, (MouseEventArgs)e);


            /*-----------第二次装料-----------*/

            //标定桶伺服回到下料口

            //套筒气缸打开

            //6分气缸开合2


            //套筒气缸松开

            //标定桶模组移动到捣棒位

            //捣棒气杆下降加磁吸起捣棒

            //捣棒伺服下降到料位2

            //捣棒磁吸消磁捣棒下落

            //捣棒伺服上升


            /*-----------第三次装料-----------*/
            //标定桶伺服伺服回到下料口

            //套筒气缸打开

            //6分气缸开合3

            //套筒气缸松开

            //标定桶模组移动到捣棒位

            //捣棒气杆下降加磁吸起捣棒

            //捣棒伺服下降到料位3

            //捣棒磁吸消磁捣棒下落

            //捣棒伺服上升

            //标定桶伺服在刮刀位来回移动刮平

            //标定桶伺服移动到取料位

            //关闭伺服使能状态
            await Task.Delay(2 * 1000);
            await ProcessWithConditionAsync("拆模压机伺服1", 0);

            if ((short)siemens.Read(DataType.DataBlock, 3, 274, VarType.Int, 1) == 1)
                btn_震动升降伺服2使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 308, VarType.Int, 1) == 1)
                btn_层间升降伺服使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 376, VarType.Int, 1) == 1)
                btn_震动升降伺服3使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 410, VarType.Int, 1) == 1)
                btn_拆模压机伺服1使能.PerformClick();
        }

        private async void btn_试模输送正向_Click(object sender, EventArgs e)
        {
            //初始化状态 
            //伺服驱动器使能
            if ((short)siemens.Read(DataType.DataBlock, 3, 274, VarType.Int, 1) == 0)
                btn_震动升降伺服2使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 308, VarType.Int, 1) == 0)
                btn_层间升降伺服使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 376, VarType.Int, 1) == 0)
                btn_震动升降伺服3使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 410, VarType.Int, 1) == 0)
                btn_拆模压机伺服1使能.PerformClick();


            //震动升降模组1移动到震动台

            //震动台气缸压紧

            //震动台震动

            //震动升降模组1移动到下料口

            //震动升降2-3号模组联动移动到升降台
            //await Task.Delay(1 * 1000);
            ////await ProcessWithConditionAsync("桶盖伺服", -70);
            ////Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            //txt_震动升降伺服1模式设定.Text = "2";
            //btn_震动升降伺服1模式设定.PerformClick();
            //txt_震动升降伺服1目标位置.Text = "0";
            //btn_震动升降伺服1目标位置.PerformClick();
            //btn_震动升降伺服1使能.PerformClick();
            //await Task.Delay(1 * 1000);
            //btn_震动升降伺服1启动_MouseDown(sender, (MouseEventArgs)e);
            //btn_震动升降伺服1启动_MouseUp(sender, (MouseEventArgs)e);

            //拆模压机模组移动到升降位
            await Task.Delay(2 * 1000);
            //await ProcessWithConditionAsync("层间升降伺服", 37.5f);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_拆模压机伺服1目标位置.Text = "47.7";
            btn_拆模压机伺服1目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_拆模压机伺服1启动_MouseDown(sender, (MouseEventArgs)e);
            btn_拆模压机伺服1启动_MouseUp(sender, (MouseEventArgs)e);


            //震动升降伺服2
            await Task.Delay(1 * 1000);
            await ProcessWithConditionAsync("拆模压机伺服1", 47.7f);
            //await ProcessWithConditionAsync("震动升降伺服2", 67);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_震动升降伺服2目标位置.Text = "0";
            btn_震动升降伺服2目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_震动升降伺服2启动_MouseDown(sender, (MouseEventArgs)e);
            btn_震动升降伺服2启动_MouseUp(sender, (MouseEventArgs)e);

            //升降台下降
            await ProcessWithConditionAsync("震动升降伺服2", 0);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_层间升降伺服目标位置.Text = "6.6";
            btn_层间升降伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_层间升降伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_层间升降伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //震动升降伺服3
            //await Task.Delay(1 * 1000);
            await ProcessWithConditionAsync("层间升降伺服", 6.6f);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_震动升降伺服3目标位置.Text = "23";
            btn_震动升降伺服3目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_震动升降伺服3启动_MouseDown(sender, (MouseEventArgs)e);
            btn_震动升降伺服3启动_MouseUp(sender, (MouseEventArgs)e);

            //升降台下降
            await ProcessWithConditionAsync("震动升降伺服3", 23);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_层间升降伺服目标位置.Text = "0";
            btn_层间升降伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_层间升降伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_层间升降伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //震动升降模组3回撤
            //await Task.Delay(1 * 1000);
            await ProcessWithConditionAsync("层间升降伺服", 0);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_震动升降伺服3目标位置.Text = "0";
            btn_震动升降伺服3目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_震动升降伺服3启动_MouseDown(sender, (MouseEventArgs)e);
            btn_震动升降伺服3启动_MouseUp(sender, (MouseEventArgs)e);

            //升降台上升
            await ProcessWithConditionAsync("震动升降伺服3", 0);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_层间升降伺服目标位置.Text = "37.5";
            btn_层间升降伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_层间升降伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_层间升降伺服启动_MouseUp(sender, (MouseEventArgs)e);


            //拆模压机模组1移动到工作台
            await ProcessWithConditionAsync("层间升降伺服", 37.5f);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_拆模压机伺服1目标位置.Text = "0";
            btn_拆模压机伺服1目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_拆模压机伺服1启动_MouseDown(sender, (MouseEventArgs)e);
            btn_拆模压机伺服1启动_MouseUp(sender, (MouseEventArgs)e);


            

            ////额外返回过去的流程
            ////磁吸下降
            //await ProcessWithConditionAsync("磁吸伺服", 0);
            //await Task.Delay(5 * 1000);
            ////Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            //txt_磁吸伺服模式设定.Text = "2";
            //btn_磁吸伺服模式设定.PerformClick();
            //txt_磁吸伺服目标位置.Text = "35";
            //btn_磁吸伺服目标位置.PerformClick();
            //btn_磁吸伺服使能.PerformClick();
            //await Task.Delay(1 * 1000);
            //btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            //btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            ////磁吸上电吸起压头
            //await ProcessWithConditionAsync("磁吸伺服", 35);
            ////await Task.Delay(20 * 1000);
            ////Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            //btn_吸盘1A启.PerformClick();
            //await Task.Delay(5 * 1000);
            ////Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            ////btn_水阀11停.PerformClick();

            ////平行移动模组移动到暂存台
            //await ProcessWithConditionAsync("磁吸伺服", 35);
            ////Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            //txt_平行移动伺服左模式设定.Text = "2";
            //btn_平行移动伺服左模式设定.PerformClick();
            //txt_平行移动伺服左目标位置.Text = "35";
            //btn_平行移动伺服左目标位置.PerformClick();
            //btn_平行移动伺服左使能.PerformClick();
            //await Task.Delay(1 * 1000);
            //btn_平行移动伺服左启动_MouseDown(sender, (MouseEventArgs)e);
            //btn_平行移动伺服左启动_MouseUp(sender, (MouseEventArgs)e);

            ////跨坐模组移动到暂存台
            //await ProcessWithConditionAsync("平行移动伺服左", 35);
            ////Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            //txt_跨坐伺服模式设定.Text = "2";
            //btn_跨坐伺服模式设定.PerformClick();
            //txt_跨坐伺服目标位置.Text = "35";
            //btn_跨坐伺服目标位置.PerformClick();
            //btn_跨坐伺服使能.PerformClick();
            //await Task.Delay(1 * 1000);
            //btn_跨坐伺服启动_MouseDown(sender, (MouseEventArgs)e);
            //btn_跨坐伺服启动_MouseUp(sender, (MouseEventArgs)e);

            ////磁吸模组下降
            //await ProcessWithConditionAsync("跨坐伺服", 35);
            ////Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            //txt_磁吸伺服模式设定.Text = "2";
            //btn_磁吸伺服模式设定.PerformClick();
            //txt_磁吸伺服目标位置.Text = "35";
            //btn_磁吸伺服目标位置.PerformClick();
            ////btn_磁吸伺服使能.PerformClick();
            //await Task.Delay(1 * 1000);
            //btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            //btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            ////磁吸下电放下压头
            //await ProcessWithConditionAsync("磁吸伺服", 35);
            ////await Task.Delay(20 * 1000);
            ////Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            ////btn_吸盘1A启.PerformClick();
            //await Task.Delay(1 * 1000);
            ////Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            //btn_吸盘1A停.PerformClick();



            //拆模压机模组1-2-3联动移动到压机

            //关闭伺服使能状态
            await Task.Delay(2 * 1000);
            await ProcessWithConditionAsync("拆模压机伺服1", 0);

            if ((short)siemens.Read(DataType.DataBlock, 3, 274, VarType.Int, 1) == 1)
                btn_震动升降伺服2使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 308, VarType.Int, 1) == 1)
                btn_层间升降伺服使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 376, VarType.Int, 1) == 1)
                btn_震动升降伺服3使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 410, VarType.Int, 1) == 1)
                btn_拆模压机伺服1使能.PerformClick();

        }

        private async void btn_试模输送逆向_Click(object sender, EventArgs e)
        {
            //初始化状态 
            //伺服驱动器使能
            if ((short)siemens.Read(DataType.DataBlock, 3, 274, VarType.Int, 1) == 0)
                btn_震动升降伺服2使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 308, VarType.Int, 1) == 0)
                btn_层间升降伺服使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 376, VarType.Int, 1) == 0)
                btn_震动升降伺服3使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 410, VarType.Int, 1) == 0)
                btn_拆模压机伺服1使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 478, VarType.Int, 1) == 0)
                btn_倒料伺服使能.PerformClick();


            //升降台下降
            await Task.Delay(1 * 1000);
            await ProcessWithConditionAsync("拆模压机伺服1", 0);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_层间升降伺服目标位置.Text = "36.5";
            btn_层间升降伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_层间升降伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_层间升降伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //倒料伺服翻转5度
            await Task.Delay(1 * 1000);
            await ProcessWithConditionAsync("层间升降伺服", 36.5f);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_倒料伺服目标位置.Text = "5";
            btn_倒料伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_倒料伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_倒料伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //拆模压机模组1移动到工作台
            await ProcessWithConditionAsync("倒料伺服", 5f);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_拆模压机伺服1目标位置.Text = "47.7";
            btn_拆模压机伺服1目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_拆模压机伺服1启动_MouseDown(sender, (MouseEventArgs)e);
            btn_拆模压机伺服1启动_MouseUp(sender, (MouseEventArgs)e);

            //升降台下降
            //await Task.Delay(1 * 1000);
            await ProcessWithConditionAsync("拆模压机伺服1", 47.7f);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_层间升降伺服目标位置.Text = "0";
            btn_层间升降伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_层间升降伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_层间升降伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //震动升降伺服3
            //await Task.Delay(1 * 1000);
            await ProcessWithConditionAsync("层间升降伺服", 0);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_震动升降伺服3目标位置.Text = "23";
            btn_震动升降伺服3目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_震动升降伺服3启动_MouseDown(sender, (MouseEventArgs)e);
            btn_震动升降伺服3启动_MouseUp(sender, (MouseEventArgs)e);

            //升降台上升
            //await Task.Delay(1 * 1000);
            await ProcessWithConditionAsync("震动升降伺服3", 23f);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_层间升降伺服目标位置.Text = "7.6";
            btn_层间升降伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_层间升降伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_层间升降伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //震动升降伺服3
            //await Task.Delay(1 * 1000);
            await ProcessWithConditionAsync("层间升降伺服", 7.6f);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_震动升降伺服3目标位置.Text = "0";
            btn_震动升降伺服3目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_震动升降伺服3启动_MouseDown(sender, (MouseEventArgs)e);
            btn_震动升降伺服3启动_MouseUp(sender, (MouseEventArgs)e);

            await ProcessWithConditionAsync("震动升降伺服3", 0);
            //await ProcessWithConditionAsync("震动升降伺服2", 67);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_震动升降伺服2目标位置.Text = "67";
            btn_震动升降伺服2目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_震动升降伺服2启动_MouseDown(sender, (MouseEventArgs)e);
            btn_震动升降伺服2启动_MouseUp(sender, (MouseEventArgs)e);

            //关闭伺服使能状态
            //关闭伺服使能
            await Task.Delay(2 * 1000);
            await ProcessWithConditionAsync("震动升降伺服2", 67);

            if ((short)siemens.Read(DataType.DataBlock, 3, 274, VarType.Int, 1) == 1)
                btn_震动升降伺服2使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 308, VarType.Int, 1) == 1)
                btn_层间升降伺服使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 376, VarType.Int, 1) == 1)
                btn_震动升降伺服3使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 410, VarType.Int, 1) == 1)
                btn_拆模压机伺服1使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 478, VarType.Int, 1) == 1)
                btn_倒料伺服使能.PerformClick();

        }



        async Task ProcessWithConditionAsync(string source, float var)
        {
            while (true)
            {
                // 异步等待一段时间（避免阻塞）
                await Task.Delay(100); // 每100毫秒检查一次

                // 检查条件
                if (CheckCondition(source, var))
                {
                    break; // 条件满足，退出循环
                }
            }

            // 条件满足后继续执行的代码
            Console.WriteLine("条件已满足，继续执行...");
        }

        bool CheckCondition(string source, float var)
        {
            switch (source)
            {
                case "捣棒伺服":
                    // 返回你的业务逻辑条件
                    float 捣棒伺服实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 24, VarType.Real, 1);
                    return 捣棒伺服实际位置 == var; // 示例：当秒数≥30时继续

                case "标定桶伺服":
                    // 返回你的业务逻辑条件
                    float 标定桶伺服实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 58, VarType.Real, 1);
                    return 标定桶伺服实际位置 == var; // 示例：当秒数≥30时继续

                case "平行移动伺服左":
                    // 返回你的业务逻辑条件
                    float 平行移动伺服左实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 92, VarType.Real, 1);
                    return 平行移动伺服左实际位置 == var; // 示例：当秒数≥30时继续

                case "平行移动伺服右":
                    // 返回你的业务逻辑条件
                    float 平行移动伺服右实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 126, VarType.Real, 1);
                    return 平行移动伺服右实际位置 == var; // 示例：当秒数≥30时继续

                case "跨坐伺服":
                    // 返回你的业务逻辑条件
                    float 跨坐伺服实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 160, VarType.Real, 1);
                    return 跨坐伺服实际位置 == var; // 示例：当秒数≥30时继续

                case "毛刷伺服":
                    // 返回你的业务逻辑条件
                    float 毛刷伺服实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 194, VarType.Real, 1);
                    return 毛刷伺服实际位置 == var; // 示例：当秒数≥30时继续

                case "磁吸伺服":
                    // 返回你的业务逻辑条件
                    float 磁吸伺服实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 228, VarType.Real, 1);
                    return 磁吸伺服实际位置 == var; // 示例：当秒数≥30时继续

                case "震动升降伺服1":
                    // 返回你的业务逻辑条件
                    float 震动升降伺服1实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 262, VarType.Real, 1);
                    return 震动升降伺服1实际位置 == var; // 示例：当秒数≥30时继续

                case "震动升降伺服2":
                    // 返回你的业务逻辑条件
                    float 震动升降伺服2实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 296, VarType.Real, 1);
                    return 震动升降伺服2实际位置 == var; // 示例：当秒数≥30时继续

                case "震动升降伺服3":
                    // 返回你的业务逻辑条件
                    float 震动升降伺服3实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 398, VarType.Real, 1);
                    return 震动升降伺服3实际位置 == var; // 示例：当秒数≥30时继续

                case "层间升降伺服":
                    // 返回你的业务逻辑条件
                    float 层间升降伺服实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 330, VarType.Real, 1);
                    return 层间升降伺服实际位置 == var; // 示例：当秒数≥30时继续

                case "倒料伺服":
                    // 返回你的业务逻辑条件
                    float 倒料伺服实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 500, VarType.Real, 1);
                    return 倒料伺服实际位置 == var; // 示例：当秒数≥30时继续

                case "拆模压机伺服1":
                    // 返回你的业务逻辑条件
                    float 拆模压机伺服1实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 432, VarType.Real, 1);
                    return 拆模压机伺服1实际位置 == var; // 示例：当秒数≥30时继续

                case "拆模压机伺服2":
                    // 返回你的业务逻辑条件
                    float 拆模压机伺服2实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 466, VarType.Real, 1);
                    return 拆模压机伺服2实际位置 == var; // 示例：当秒数≥30时继续

                case "拆模压机伺服3":
                    // 返回你的业务逻辑条件
                    float 拆模压机伺服3实际位置 = (float)siemens.Read(DataType.DataBlock, 3, 364, VarType.Real, 1);
                    return 拆模压机伺服3实际位置 == var; // 示例：当秒数≥30时继续

                default:
                    break;
            }
            return false;
        }



        private void btn_一键启动3_Click(object sender, EventArgs e)
        {
            //拆模压机模组1-2-3联动移动到工作台

            //磁吸模组下降吸起压头

            //平行移动模组移动到刷排

            //磁吸模组下降到刷排

            //磁吸旋转电机转动

            //磁吸模组上升

            //平行移动模组移动到暂存台

            //跨坐模组移动到暂存台

            //磁吸模组下降放下压头

            //平行移动模组移动到工作台

            //跨坐模组移动到工作台

            //磁吸模组下降吸起桶身

            //爆锤动作

            //磁吸上升收起桶身

            //拆模压机模组1后移收起

            //工作台翻转180

            //工作台翻回向上

            //拆模压机模组1前移到工作位

            //磁吸模组下降

            //拆模压机模组1气杆压紧桶身

            //磁吸模组上升

            //跨坐模组移动毛刷到桶身上方

            //毛刷模组下降

            //毛刷电机旋转

            //毛刷电机上升

            //跨坐模组移动磁吸到桶身上方

            //磁吸模组下降吸起桶身

            //磁吸模组上升

            //平行移动模组移动到暂存位

            //跨坐模组移动到暂存位

            //工作台翻转180

            //工作台翻回向上

            //工作台消磁

            //磁吸模组下降吸起底板

            //磁吸模组上升

            //平行移动模组移动到暂存位

            //跨坐模组移动到暂存位

            //磁吸模组下降放下底板

        }

        private void checkBox_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox cb = (CheckBox)sender;
            if (cb.Checked)
            {
                cb.BackColor = Color.Red; // 选中时的颜色
                cb.ForeColor = Color.Black; // 文字颜色
            }
            else
            {
                cb.BackColor = SystemColors.Control; // 默认背景色
                cb.ForeColor = SystemColors.ControlText; // 默认文字颜色
            }
        }

        private void btn_电机1反_Click(object sender, EventArgs e)
        {
            //bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 6, VarType.Bit, 1, 5);
            //Console.WriteLine($"读取值: {valueRead}");
            //if ((bool)siemens.Read(DataType.DataBlock, 2, 6, VarType.Bit, 1, 5))
            //{
            //    siemens.WriteBit(DataType.DataBlock, 2, 6, 5, false);
            //    //siemens.Write("DB4.DBW2", (short)0);
            //}
            //else
            //{
            //    siemens.WriteBit(DataType.DataBlock, 2, 6, 5, true);
            //    //siemens.Write("DB4.DBW2", (short)1);
            //}

        }

        private void btn_电机2反_Click(object sender, EventArgs e)
        {
            bool valueRead = (bool)siemens.Read(DataType.DataBlock, 2, 6, VarType.Bit, 1, 5);
            Console.WriteLine($"读取值: {valueRead}");
            if ((bool)siemens.Read(DataType.DataBlock, 2, 6, VarType.Bit, 1, 5))
            {
                siemens.WriteBit(DataType.DataBlock, 2, 6, 5, false);
                //siemens.Write("DB4.DBW2", (short)0);
            }
            else
            {
                siemens.WriteBit(DataType.DataBlock, 2, 6, 5, true);
                //siemens.Write("DB4.DBW2", (short)1);
            }
        }

        private async void btn_装模流程_Click(object sender, EventArgs e)
        {
            //初始化状态 
            //伺服驱动器使能
            if ((short)siemens.Read(DataType.DataBlock, 3, 274, VarType.Int, 1) == 0)
                btn_平行移动伺服左使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 308, VarType.Int, 1) == 0)
                btn_跨坐伺服使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 376, VarType.Int, 1) == 0)
                btn_磁吸伺服使能.PerformClick();
            //if ((short)siemens.Read(DataType.DataBlock, 3, 410, VarType.Int, 1) == 0)
            //    btn_拆模压机伺服1使能.PerformClick();

            //平行移动伺服到压头暂存位
            //await ProcessWithConditionAsync("拆模压机伺服1", 35);
            await Task.Delay(1 * 1000);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_平行移动伺服左目标位置.Text = "35";
            btn_平行移动伺服左目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_平行移动伺服左启动_MouseDown(sender, (MouseEventArgs)e);
            btn_平行移动伺服左启动_MouseUp(sender, (MouseEventArgs)e);

            //跨坐伺服到压头暂存位
            await ProcessWithConditionAsync("平行移动伺服左", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_跨坐伺服目标位置.Text = "35";
            btn_跨坐伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_跨坐伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_跨坐伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸伺服下降到压头
            await ProcessWithConditionAsync("跨坐伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_磁吸伺服目标位置.Text = "35";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸上电吸起压头
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            btn_吸盘1A启.PerformClick();
            //await Task.Delay(5 * 1000);
            //btn_水阀11停.PerformClick();


            //磁吸伺服上升
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_磁吸伺服目标位置.Text = "45";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //平行移动伺服到压头工作位
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_平行移动伺服左目标位置.Text = "35";
            btn_平行移动伺服左目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_平行移动伺服左启动_MouseDown(sender, (MouseEventArgs)e);
            btn_平行移动伺服左启动_MouseUp(sender, (MouseEventArgs)e);

            //跨坐伺服到压头工作位
            await ProcessWithConditionAsync("平行移动伺服左", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_跨坐伺服目标位置.Text = "35";
            btn_跨坐伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_跨坐伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_跨坐伺服启动_MouseUp(sender, (MouseEventArgs)e);


            //磁吸伺服下降到桶身
            await ProcessWithConditionAsync("跨坐伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_磁吸伺服目标位置.Text = "35";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸电机左转和右转
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            btn_电机2启.PerformClick();
            await Task.Delay(5 * 1000);
            btn_电机2停.PerformClick();
            await Task.Delay(2 * 1000);
            btn_电机2反.PerformClick();
            btn_电机2启.PerformClick();
            await Task.Delay(5 * 1000);
            btn_电机2停.PerformClick();

            //磁吸下电放下压头
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            //btn_吸盘1A启.PerformClick();
            await Task.Delay(1 * 1000);
            btn_吸盘1A停.PerformClick();

            //磁吸上升
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(2 * 1000);
            txt_磁吸伺服目标位置.Text = "0";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //关闭伺服使能状态
            await Task.Delay(2 * 1000);
            await ProcessWithConditionAsync("磁吸伺服", 0);

            if ((short)siemens.Read(DataType.DataBlock, 3, 274, VarType.Int, 1) == 1)
                btn_平行移动伺服左使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 308, VarType.Int, 1) == 1)
                btn_跨坐伺服使能.PerformClick();
            if ((short)siemens.Read(DataType.DataBlock, 3, 376, VarType.Int, 1) == 1)
                btn_磁吸伺服使能.PerformClick();


        }

        private async void btn_拆模流程_Click(object sender, EventArgs e)
        {
            //平行移动模组移动到工作位
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_平行移动伺服左目标位置.Text = "35";
            btn_平行移动伺服左目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_平行移动伺服左启动_MouseDown(sender, (MouseEventArgs)e);
            btn_平行移动伺服左启动_MouseUp(sender, (MouseEventArgs)e);

            //跨坐伺服移动到工作位
            await ProcessWithConditionAsync("平行移动伺服左", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_跨坐伺服目标位置.Text = "35";
            btn_跨坐伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_跨坐伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_跨坐伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸模组下降到压头
            await ProcessWithConditionAsync("跨坐伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_磁吸伺服目标位置.Text = "35";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸上电
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            //btn_吸盘1A启.PerformClick();
            await Task.Delay(1 * 1000);
            btn_吸盘1A停.PerformClick();

            //磁吸模组上升
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(2 * 1000);
            txt_磁吸伺服目标位置.Text = "0";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //平行移动模组移动到刷子位
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_平行移动伺服左目标位置.Text = "35";
            btn_平行移动伺服左目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_平行移动伺服左启动_MouseDown(sender, (MouseEventArgs)e);
            btn_平行移动伺服左启动_MouseUp(sender, (MouseEventArgs)e);

            //跨坐伺服移动到刷子位
            await ProcessWithConditionAsync("平行移动伺服左", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_跨坐伺服目标位置.Text = "35";
            btn_跨坐伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_跨坐伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_跨坐伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸模组下降到刷排
            await ProcessWithConditionAsync("跨坐伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_磁吸伺服目标位置.Text = "35";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸电机正反转
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            btn_电机2启.PerformClick();
            await Task.Delay(5 * 1000);
            btn_电机2停.PerformClick();
            await Task.Delay(2 * 1000);
            btn_电机2反.PerformClick();
            btn_电机2启.PerformClick();
            await Task.Delay(5 * 1000);
            btn_电机2停.PerformClick();

            //磁吸模组上升
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(2 * 1000);
            txt_磁吸伺服目标位置.Text = "0";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //平行移动模组移动到暂存位
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_平行移动伺服左目标位置.Text = "35";
            btn_平行移动伺服左目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_平行移动伺服左启动_MouseDown(sender, (MouseEventArgs)e);
            btn_平行移动伺服左启动_MouseUp(sender, (MouseEventArgs)e);

            //跨坐伺服移动到暂存位
            await ProcessWithConditionAsync("平行移动伺服左", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_跨坐伺服目标位置.Text = "35";
            btn_跨坐伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_跨坐伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_跨坐伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸模组下降到暂存位
            await ProcessWithConditionAsync("跨坐伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_磁吸伺服目标位置.Text = "35";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸下电
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            btn_吸盘1A启.PerformClick();
            //await Task.Delay(5 * 1000);
            //btn_水阀11停.PerformClick();

            //磁吸模组上升
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_磁吸伺服目标位置.Text = "45";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //平行移动模组移动到工作位
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_平行移动伺服左目标位置.Text = "35";
            btn_平行移动伺服左目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_平行移动伺服左启动_MouseDown(sender, (MouseEventArgs)e);
            btn_平行移动伺服左启动_MouseUp(sender, (MouseEventArgs)e);

            //跨坐伺服移动到工作位
            await ProcessWithConditionAsync("平行移动伺服左", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_跨坐伺服目标位置.Text = "35";
            btn_跨坐伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_跨坐伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_跨坐伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸模组下降到桶身
            await ProcessWithConditionAsync("跨坐伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_磁吸伺服目标位置.Text = "35";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸上电
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            //btn_吸盘1A启.PerformClick();
            await Task.Delay(1 * 1000);
            btn_吸盘1A停.PerformClick();

            //吸起桶身到敲击位
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(2 * 1000);
            txt_磁吸伺服目标位置.Text = "0";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);


            //爆锤敲击
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            btn_吸盘1A启.PerformClick();
            //await Task.Delay(5 * 1000);
            //btn_水阀11停.PerformClick();


            //磁吸模组上升
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_磁吸伺服目标位置.Text = "45";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);


            //拆模压机伺服收起
            await ProcessWithConditionAsync("跨坐伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_磁吸伺服目标位置.Text = "35";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //倒料伺服翻转180
            await ProcessWithConditionAsync("倒料伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_倒料伺服目标位置.Text = "35";
            btn_倒料伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_倒料伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_倒料伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //倒料伺服归位向上
            await ProcessWithConditionAsync("倒料伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_倒料伺服目标位置.Text = "35";
            btn_倒料伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_倒料伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_倒料伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //拆模压机伺服移动到工作位
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(2 * 1000);
            txt_磁吸伺服目标位置.Text = "0";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸伺服下降
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(2 * 1000);
            txt_磁吸伺服目标位置.Text = "0";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸下电
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            btn_吸盘1A启.PerformClick();
            //await Task.Delay(5 * 1000);
            //btn_水阀11停.PerformClick();

            //磁吸伺服上升
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(2 * 1000);
            txt_磁吸伺服目标位置.Text = "0";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //平行移动模组移动毛刷到工作位
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_平行移动伺服左目标位置.Text = "35";
            btn_平行移动伺服左目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_平行移动伺服左启动_MouseDown(sender, (MouseEventArgs)e);
            btn_平行移动伺服左启动_MouseUp(sender, (MouseEventArgs)e);

            //跨坐伺服移动毛刷到工作位
            await ProcessWithConditionAsync("平行移动伺服左", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_跨坐伺服目标位置.Text = "35";
            btn_跨坐伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_跨坐伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_跨坐伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //毛刷模组下降到桶身
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(2 * 1000);
            txt_磁吸伺服目标位置.Text = "0";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //毛刷电机正反转
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            btn_电机2启.PerformClick();
            await Task.Delay(5 * 1000);
            btn_电机2停.PerformClick();
            await Task.Delay(2 * 1000);
            btn_电机2反.PerformClick();
            btn_电机2启.PerformClick();
            await Task.Delay(5 * 1000);

            //毛刷伺服上升
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(2 * 1000);
            txt_磁吸伺服目标位置.Text = "0";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //平行移动模组移动磁吸到工作位
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_平行移动伺服左目标位置.Text = "35";
            btn_平行移动伺服左目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_平行移动伺服左启动_MouseDown(sender, (MouseEventArgs)e);
            btn_平行移动伺服左启动_MouseUp(sender, (MouseEventArgs)e);

            //跨坐伺服移动磁吸到工作位
            await ProcessWithConditionAsync("平行移动伺服左", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_跨坐伺服目标位置.Text = "35";
            btn_跨坐伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_跨坐伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_跨坐伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸下降到桶身
            await ProcessWithConditionAsync("跨坐伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_磁吸伺服目标位置.Text = "35";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸上电
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            btn_吸盘1A启.PerformClick();
            //await Task.Delay(5 * 1000);
            //btn_水阀11停.PerformClick();

            //磁吸伺服上升
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_磁吸伺服目标位置.Text = "45";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //平行移动模组移动到暂存位
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_平行移动伺服左目标位置.Text = "35";
            btn_平行移动伺服左目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_平行移动伺服左启动_MouseDown(sender, (MouseEventArgs)e);
            btn_平行移动伺服左启动_MouseUp(sender, (MouseEventArgs)e);

            //跨坐伺服移动到暂存位
            await ProcessWithConditionAsync("平行移动伺服左", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_跨坐伺服目标位置.Text = "35";
            btn_跨坐伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_跨坐伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_跨坐伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸模组下降到暂存位
            await ProcessWithConditionAsync("跨坐伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_磁吸伺服目标位置.Text = "35";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸下电
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            btn_吸盘1A启.PerformClick();
            //await Task.Delay(5 * 1000);
            //btn_水阀11停.PerformClick();

            //磁吸模组上升
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_磁吸伺服目标位置.Text = "45";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //平行移动模组移动到工作位位
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_平行移动伺服左目标位置.Text = "35";
            btn_平行移动伺服左目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_平行移动伺服左启动_MouseDown(sender, (MouseEventArgs)e);
            btn_平行移动伺服左启动_MouseUp(sender, (MouseEventArgs)e);

            //跨坐伺服移动到工作位
            await ProcessWithConditionAsync("平行移动伺服左", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_跨坐伺服目标位置.Text = "35";
            btn_跨坐伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_跨坐伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_跨坐伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸伺服下降到底板
            await ProcessWithConditionAsync("跨坐伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_磁吸伺服目标位置.Text = "35";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸上电
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            //btn_吸盘1A启.PerformClick();
            await Task.Delay(1 * 1000);
            btn_吸盘1A停.PerformClick();

            //磁吸伺服上升
            await ProcessWithConditionAsync("跨坐伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_磁吸伺服目标位置.Text = "35";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //平行移动模组移动到暂存位
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_平行移动伺服左目标位置.Text = "35";
            btn_平行移动伺服左目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_平行移动伺服左启动_MouseDown(sender, (MouseEventArgs)e);
            btn_平行移动伺服左启动_MouseUp(sender, (MouseEventArgs)e);

            //跨坐伺服移动到暂存位
            await ProcessWithConditionAsync("平行移动伺服左", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_跨坐伺服目标位置.Text = "35";
            btn_跨坐伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_跨坐伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_跨坐伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸模组下降到暂存位
            await ProcessWithConditionAsync("跨坐伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_磁吸伺服目标位置.Text = "35";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);

            //磁吸下电
            await ProcessWithConditionAsync("磁吸伺服", 35);
            //await Task.Delay(20 * 1000);
            //btn_吸盘1A启.PerformClick();
            await Task.Delay(1 * 1000);
            btn_吸盘1A停.PerformClick();

            //拆模压机伺服收起
            await ProcessWithConditionAsync("跨坐伺服", 35);
            //Console.WriteLine("调用-" + System.DateTime.Now.ToString("HH:mm:ss.fff"));
            txt_磁吸伺服目标位置.Text = "35";
            btn_磁吸伺服目标位置.PerformClick();
            await Task.Delay(1 * 1000);
            btn_磁吸伺服启动_MouseDown(sender, (MouseEventArgs)e);
            btn_磁吸伺服启动_MouseUp(sender, (MouseEventArgs)e);
        }

        private void btn_实时刷新状态_Click(object sender, EventArgs e)
        {
            btn_实时刷新状态.BackColor = Color.DodgerBlue;
            btn_停止刷新状态.BackColor = Color.FromArgb(0, 0, 64);
            // 启动计时器，每秒更新一次（1000毫秒）
            if (siemens != null && siemens.IsConnected)
            {
                _timer5.Change(0, 1000);

            }
            else
            {

            }
        }

        private void btn_停止刷新状态_Click(object sender, EventArgs e)
        {
            btn_实时刷新状态.BackColor = Color.FromArgb(0, 0, 64);
            btn_停止刷新状态.BackColor = Color.DodgerBlue;
            // 停止计时器
            _timer5.Change(Timeout.Infinite, Timeout.Infinite);
        }

        private void tb_Click(object sender, EventArgs e)
        {
            TextBox tb_temp = (TextBox)sender;
            FrmSoftKey.input = tb_temp.Text;
            // 获取 TextBox 的屏幕位置
            Point textboxLocation = tb_temp.PointToScreen(Point.Empty);
            // 创建一个新的窗体
            FrmSoftKey frmSoftKey = new FrmSoftKey();
            // 计算窗体的位置
            int popupX = textboxLocation.X;
            int popupY = textboxLocation.Y + tb_temp.Size.Height;
            // 设置窗体的位置
            frmSoftKey.Location = new Point(popupX, popupY);
            // 显示窗体
            frmSoftKey.ShowDialog();
            //MessageBox.Show("显示键盘之后");
            //MessageBox.Show(FrmSoftKey.input);
            if (FrmSoftKey.confirm)
            {
                tb_temp.Text = FrmSoftKey.input;
                tb_temp.SelectionStart = tb_temp.Text.Length;
                tb_temp.SelectionLength = 0;
                tb_temp.Focus();
            }
        }
    }
}
